How to use the rxjs/operators.take 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 particl / particl-desktop / src / app / loading / loading.component.ts View on Github external
ngOnInit() {
    this.log.i('Loading component booted!');

    /* Daemon download  */
    this.updater.status.asObservable().subscribe(status => {
      this.log.d(`updating statusMessage: `, status);
      this.loadingMessage = status;
    });

    // we wait until the multiwallet has retrieved the wallets
    this.multi.list.pipe(take(1)).subscribe(wallets => {
      // we also pass through the loading screen to switch wallets
      // check if a wallet was specified
      this.route.queryParamMap.pipe(take(1)).subscribe((params: ParamMap) => {
        this.log.d('loading params', params);
        // we can only pass strings through
        const switching = params.get('wallet');
        if (switching !== null && switching !== undefined) {
          // one was specified
          this.rpc.wallet = switching;
        }

        this.con.performCheck();

        // kick off the connection checker
        // only after we have a wallet or default
        this.con
github dotCMS / core-web / src / app / portlets / dot-edit-page / layout / dot-edit-layout-designer / dot-edit-layout-designer.component.ts View on Github external
private setupLayout(pageState?: DotPageRenderState): void {
        if (pageState) {
            this.pageState = pageState;
        }
        this.templateContainersCacheService.set(this.pageState.containers);
        this.initForm();
        this.saveAsTemplateHandleChange(false);
        this.dotThemesService
            .get(this.form.get('themeId').value)
            .pipe(take(1))
            .subscribe(
                (theme: DotTheme) => {
                    this.currentTheme = theme;
                },
                (error: ResponseView) => this.errorHandler(error)
            );
        // Emit event to redraw the grid when the sidebar change
        this.form
            .get('layout.sidebar')
            .valueChanges.pipe(takeUntil(this.destroy$))
            .subscribe(() => {
                this.dotEventsService.notify('layout-sidebar-change');
            });
    }
github johannesjo / super-productivity / src / app / features / google / google-api.service.ts View on Github external
private _mapHttp$(paramsIN: HttpRequest | any): Observable {
    const loginObs = this._session$.pipe(
      take(1),
      concatMap((session) => {
        const isRefreshNecessary = !session.accessToken || this._isTokenExpired(session);
        if (isRefreshNecessary) {
          return this.login(true);
        } else {
          return of(true);
        }
      })
    );

    return from(loginObs)
      .pipe(
        concatMap(() => {
          const p: any = {
            ...paramsIN,
            headers: {
github SAP / cloud-commerce-spartacus-storefront / projects / core / src / cart / facade / save-for-later.service.ts View on Github external
if (
            !this.isCreated(saveForLaterState.value.content) &&
            !saveForLaterState.loading
          ) {
            this.store.dispatch(
              new CartActions.CreateSaveForLater({
                userId: this.saveForLaterData.userId,
                cartId: this.saveForLaterData.cartId,
              })
            );
          }
        }),
        filter(saveForLaterState =>
          this.isCreated(saveForLaterState.value.content)
        ),
        take(1)
      )
      .subscribe(_ => {
        this.store.dispatch(
          new CartActions.CartAddEntry({
            userId: this.saveForLaterData.userId,
            cartId: this.saveForLaterData.cartId,
            productCode: productCode,
            quantity: quantity,
            isSaveForLater: true,
          })
        );
      });
  }
github caos / zitadel / console / src / app / pages / users / user-list / user-list.component.ts View on Github external
constructor(public translate: TranslateService, activatedRoute: ActivatedRoute) {
        activatedRoute.data.pipe(take(1)).subscribe(params => {
            const { type } = params;
            this.type = type;
        });
    }
}
github machinelabs / machinelabs / client / src / app / editor / remote-code-execution / message-stream-optimizer.ts View on Github external
getHeadMessages(executionId, partitionSize) {
    return this.db
      .executionMessageRef(executionId)
      .orderByChild('index')
      .startAt(0)
      .limitToFirst(partitionSize)
      .childAdded()
      .pipe(take(partitionSize), snapshotToValue);
  }
github particl / particl-desktop / src / app / core / market / proposals-notifier / proposals-notifications.service.ts View on Github external
loadProposals(): void {
    this.proposalsService
      .list(this.lastUpdatedTimeStamp, '*')
      .pipe(take(1))
      .subscribe((proposals: Proposal[]) => {
        let tempCount = 0;
        if (proposals.length) {
          for (let idx = proposals.length - 1; idx >= 0; idx--) {
            const proposal: Proposal = proposals[idx];
            if (proposal && (+proposal.createdAt > this.lastUpdatedTimeStamp)) {
              tempCount++;
            }
          }
          if (tempCount > 0) {
            let needUpdating = false;
            for (let idx = proposals.length - tempCount; idx < proposals.length; idx++) {
              const proposal: Proposal = proposals[idx];
              if (proposal && +proposal.createdAt > this.notifcationTimestamp) {
                needUpdating = true;
                this.notifyNewProposal(proposal);
github dotCMS / core-web / src / app / portlets / dot-edit-page / content / services / dot-page-state / dot-page-state.service.ts View on Github external
requestPage(options: DotPageRenderOptions): Observable {
        return this.dotPageRenderService.get(options).pipe(
            catchError((err: ResponseView) => this.handleSetPageStateFailed(err)),
            take(1),
            map((page: DotPageRender.Parameters) => {
                if (page) {
                    const pageState = new DotPageRenderState(this.getCurrentUser(), page);
                    this.setCurrentState(pageState);
                    return pageState;
                }

                return this.currentState;
            })
        );
    }
github dotCMS / core-web / src / app / view / components / dot-language-selector / dot-language-selector.component.ts View on Github external
private loadOptions(): void {
        this.dotLanguagesService
            .get()
            .pipe(take(1))
            .subscribe(
                (languages: DotLanguage[]) => {
                    this.options = this.decorateLabels(languages);
                    this.disabled = this.options.length === 0;
                },
                () => {
                    this.disabled = true;
                }
            );
    }
}
github SapphireDb / SapphireDb / DemoClient / projects / ng-realtime-database / src / lib / models / auth.ts View on Github external
.pipe(switchMap((response: LoginResponse) => {
        const newAuthData: AuthData = response;
        this.authData$.next(newAuthData);

        localStorage.setItem(LocalstoragePaths.authPath, JSON.stringify(newAuthData));
        const userData$ = this.getUserData();

        userData$.pipe(filter(v => !!v), take(1)).subscribe(() => {
          this.websocket.setBearer(newAuthData.authToken);
        });

        return userData$;
      }));
  }