rxjs/operators#skipWhile TypeScript Examples

The following examples show how to use rxjs/operators#skipWhile. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: router-outlet.element.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
private installFocusWithinEventDispatcher(): void {
    Beans.get(MessageClient).observe$<boolean>(RouterOutlets.focusWithinOutletTopic(this._uid))
      .pipe(
        mapToBody(),
        skipWhile(focusWithin => focusWithin === false), // wait until first receiving the focus, otherwise, it would emit immediately.
        takeUntil(this._disconnect$),
      )
      .subscribe((focusWithin: boolean) => {
        this.dispatchEvent(new CustomEvent('focuswithin', {
          detail: focusWithin,
          bubbles: false,
          cancelable: false,
        }));
      });
  }
Example #2
Source File: viewer.component.ts    From FlexDemo with MIT License 4 votes vote down vote up
ngOnInit() {

    this.activeTenant$
      .pipe(takeUntil(this.destroy$))
      .subscribe((tenant) => {
        if (tenant != null && tenant.tenantId != null) {
          this.store.dispatch([
            new SetPageSize(AssetEntityState, 50),
            new SetExpands(AssetEntityState, new Expand('Models')),
            new SetOrderBys(AssetEntityState, new SortOrder<Asset>('DateCreated', 'desc')),
            new SetFilter(AssetEntityState, 'Models/any(m:m/ProcessingStatus eq \'Completed\')')
          ]
          )
            .subscribe(() => this.store.dispatch(new GoToPage(AssetEntityState, { first: true })));
        }
      });

    this.route.queryParams
      .pipe(takeUntil(this.destroy$))
      .subscribe((p: Params) => {
        const assetIdStr = p.assetId;
        if (assetIdStr == null) {
          return;
        }
        const assetId = +assetIdStr;
        this.assets$.pipe(skipWhile(v => v == null || v.length === 0), take(1)).subscribe(assets => {
          const asset = assets.find(a => a.AssetId === assetId);
          if (asset != null) {
            this.setActive(asset);
          }
        });
      });

    // set current canvas
    const canvasContainer = document.getElementById('viewer_canvas') as HTMLElement;
    this.canvasId$
      .pipe(takeUntil(this.destroy$))
      .subscribe(canvasId => {
        if (canvasId != null) {
          canvasContainer.innerHTML = '';
          const canvas = this.canvasService.GetCanvas(canvasId);
          canvasContainer.appendChild(canvas);
        }
      });

    this.picked$
      .pipe(takeUntil(this.destroy$))
      .subscribe(pick => {
        if (pick === null || pick.length === 0) {
          return;
        }
        this.selected$.pipe(
          takeUntil(this.destroy$),
          take(1)).subscribe(selection => {
            if (selection == null || selection.length === 0) {
              this.store.dispatch(new AddEntityState(this.currentViewId, ViewerEntityState.HIGHLIGHTED, pick));

              return;
            }

            const unselect =
              pick.filter(p => selection.find(s =>
                s.entityId === p.entityId &&
                s.assetModel.assetModelId === p.assetModel.assetModelId) != null);
            const select =
              pick.filter(p => selection.find(s =>
                s.entityId !== p.entityId ||
                s.assetModel.assetModelId !== p.assetModel.assetModelId) != null);


            this.store.dispatch(new AddEntityState(this.currentViewId, ViewerEntityState.HIGHLIGHTED, select));
            this.store.dispatch(new RemoveEntityState(this.currentViewId, ViewerEntityState.HIGHLIGHTED, unselect));

          });
        this.store.dispatch(new SetDetailImage(this.currentViewId, 640, 360, pick));
      });

    this.detail$
      .pipe(takeUntil(this.destroy$))
      .subscribe(img => {
        const container = document.getElementById('detail-view');
        container.innerHTML = null;

        if (img != null) {
          img.height = 90;
          container.appendChild(img);
          this.showDetails = true;
        } else {
          this.showDetails = false;
        }
      });

    this.hoverOver$.pipe(takeUntil(this.destroy$))
      .subscribe(hov => {
        this.properties = hov;
      }, err => this.logger.error(err));

    this.actions$
      .pipe(
        takeUntil(this.destroy$),
        ofActionSuccessful(LoadModelsIntoView),
        tap(m => this.logger.debug('Setting default view', m))
      )
      .subscribe((action: LoadModelsIntoView) => {
        this.store.dispatch(new SetDefaultViewPoint(this.currentViewId, ViewType.DEFAULT));
      });

    this.activeAsset$
      .pipe(
        takeUntil(this.destroy$),
        distinctUntilChanged((a, b) => a && b && a.AssetId === b.AssetId)
      )
      .subscribe(asset => {
        if (asset) {
          this.load3DModel(asset);
        }
      });
  }