How to use the rxjs/operators.takeUntil function in rxjs

To help you get started, we’ve selected a few rxjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chef / automate / components / automate-ui / src / app / pages / api-token / list / api-token-list.component.ts View on Github external
.subscribe((state) => {
        if (!loading(state)) {
          pendingCreate.next(true);
          pendingCreate.complete();
          this.creatingToken = false;
          if (state === EntityStatus.loadingSuccess) {
            this.closeCreateModal();
            this.router.navigate(['/settings', 'tokens', tok.id]);
          }
          if (state === EntityStatus.loadingFailure) {
            const pendingCreateError = new Subject();
            this.store.pipe(
              select(saveError),
              filter(identity),
              takeUntil(pendingCreateError))
              .subscribe((error) => {
                pendingCreateError.next(true);
                pendingCreateError.complete();
                if (error.status === HttpStatus.CONFLICT) {
                  this.conflictErrorEvent.emit(true);
                // Close the modal on any error other than conflict and display in banner.
                } else {
                  this.closeCreateModal();
                }
            });
          }
        }
      });
  }
github opf / openproject / frontend / app / components / wp-inline-create / wp-inline-create.component.ts View on Github external
ngOnChanges() {
    if (_.isNil(this.table)) {
      return;
    }

    this.rowBuilder = new InlineCreateRowBuilder(this.injector, this.table);
    this.timelineBuilder = new TimelineRowBuilder(this.injector, this.table);

    // Mirror the row height in timeline
    const container = jQuery(this.table.timelineBody);
    container.addClass('-inline-create-mirror');

    // Remove temporary rows on creation of new work package
    this.wpCreate.onNewWorkPackage()
      .pipe(
        takeUntil(componentDestroyed(this))
      )
      .subscribe((wp:WorkPackageResource) => {
        if (this.currentWorkPackage && this.currentWorkPackage === wp) {
          // Add next row
          this.removeWorkPackageRow();
          this.addWorkPackageRow();

          // Focus on the last inserted id
          if (!this.table.configuration.isEmbedded) {
            this.wpTableFocus.updateFocus(wp.id);
          }
        } else {
          // Remove current row
          this.table.editing.stopEditing('new');
          this.removeWorkPackageRow();
          this.showRow();
github Rebolon / php-sf-flex-webpack-encore-vuejs / assets / js / form-devxpress-angular / src / app / book-container / book / book.component.ts View on Github external
const bookId = params.get('id')

              if (bookId === null) {
                throw new Error('Cannot access Book without any selected one')
              }

              // subscribe to the book Observable
              this.bookService
                .book
                .subscribe((res: Book) => this.book = res)

              // then do the main call
              this.bookService
                .get(parseInt(bookId, 10))
                .pipe(
                  takeUntil(this.ngUnsubscribe)
                )
                .subscribe((res: Book) => {
                  this.isLoading = false
                })
            })
    }
github SchweizerischeBundesbahnen / scion-workbench / projects / scion / mouse-dispatcher / src / lib / mouse-dispatcher.ts View on Github external
export function installMouseDispatcher(targetWindow: Window, targetOrigin: string, options?: Options): SciMouseDispatcher {
  const destroy$ = new Subject();

  // Dispatch native mouse events to the target window
  const mousemoveThrottleTime = options && options.mousemoveThrottleTime || 20;
  merge(
    fromEvent(document, 'mousemove').pipe(filter(event => event.buttons === PRIMARY_MOUSE_BUTTON), auditTime(mousemoveThrottleTime)),
    fromEvent(document, 'mouseup'),
  )
    .pipe(takeUntil(destroy$))
    .subscribe((event: MouseEvent) => {
      targetWindow.postMessage({
        type: `sci-${event.type}`,
        screenX: event.screenX,
        screenY: event.screenY,
      }, targetOrigin);
    });

  // Dispatch synthetic mouse events to the target window (unless emitted itself)
  merge(
    fromEvent(document, 'sci-mousemove'),
    fromEvent(document, 'sci-mouseup'),
  )
    .pipe(
      filter((event: SciMouseEvent) => event.source !== targetWindow),
      takeUntil(destroy$),
github reecemcd / ngx-form-resolver / projects / ngx-form-resolver / src / lib / form-resolver.ts View on Github external
const control: AbstractControl = this.formGroup.get(key);
      control.valueChanges.pipe(
          startWith(control.value),
          takeUntil(this._updateSubject.asObservable())
        ).subscribe(value => {
          if (!this._stateSubjects.hasOwnProperty(key)) {
            this._stateSubjects[key] = new Subject();
          }
          this._stateSubjects[key].next(value);
        });
    });

    // Group level changes
    this.formGroup.valueChanges.pipe(
        startWith(this.getFormStateSnapshot()),
        takeUntil(this._updateSubject.asObservable())
      ).subscribe(() => {
        this._stateSubject.next(this.getFormStateSnapshot());
      });
  }
github wardbell / rxjs-in-ng / src / app / samples / comp-alive-obs / comp-alive-obs.component.ts View on Github external
ngOnInit() {
    this.t
      .time$('CompAliveObs')
      .pipe(takeUntil(CompStillAlive(this)))
      .subscribe(
        time => (this.time = time),
        err => console.error(err),
        () => console.log('completed')
      );
  }
  ngOnDestroy(): void {
github ORCID / ORCID-Source / orcid-web / src / main / webapp / static / javascript / ng1Orcid / app / modules / peerReview / peerReview.component.ts View on Github external
getDetails(putCode): void {
        if(this.publicView === "true"){
            this.peerReviewService.getPublicPeerReviewById(putCode)
            .pipe(    
                takeUntil(this.ngUnsubscribe)
            )
            .subscribe(
                data => {
                    //this.peerReviewService.removeBadExternalIdentifiers(data);
                    this.peerReviewService.details[putCode] = data;   
                },
                error => {
                    console.log('getDetailsError', error);
                } 
            );
        } else {
            this.peerReviewService.getPeerReviewById(putCode)
            .pipe(    
                takeUntil(this.ngUnsubscribe)
            )
            .subscribe(
github tanepiper / ngx-tinynodes / libs / ngx-editorjs / ngx-editorjs-demo / src / lib / containers / page-container / page-container.component.ts View on Github external
public get blocks() {
    return this.editorService.lastChange({ holder: this.holder }).pipe(
      pluck('blocks'),
      takeUntil(this.onDestroy$)
    );
  }
github ArkEcosystem / mobile-wallet / src / app / pages / delegates / delegates.ts View on Github external
private fetchCurrentVote() {
    if (!this.currentWallet) { return; }

    this.arkApiProvider.client.getWalletVotes(this.currentWallet.address)
      .pipe(
        takeUntil(this.unsubscriber$)
      )
      .subscribe((data) => {
        if (data.success && data.delegates.length > 0) {
          this.walletVote = data.delegates[0];
        }
      }, () => {
        this.toastProvider.error('DELEGATES_PAGE.VOTE_FETCH_ERROR');
      });
  }
github SchweizerischeBundesbahnen / scion-workbench / projects / scion / workbench / src / lib / spec / view-part.model.spec.ts View on Github external
constructor(public view: WorkbenchView) {
    view.active$
      .pipe(takeUntil(this._destroy$))
      .subscribe(active => this.activated = active);
  }