當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Store.select方法代碼示例

本文整理匯總了TypeScript中@ngxs/store.Store.select方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Store.select方法的具體用法?TypeScript Store.select怎麽用?TypeScript Store.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ngxs/store.Store的用法示例。


在下文中一共展示了Store.select方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: ngOnInit

  ngOnInit() {
    this.store.select(UiState.currentPage).subscribe(currentPage => {
      this.currentPage = currentPage;
    });

    this.store.select(UiState.currentLayer).subscribe(currentLayer => {
      if (this.ref) {
        this.ref.selectDomNode(currentLayer);
      }
    });
  }
開發者ID:Julianhm9612,項目名稱:xlayers,代碼行數:11,代碼來源:sketch-container.component.ts

示例2: ngxsOnInit

  ngxsOnInit({ dispatch }: StateContext<ShopProductsModel>) {
    concat(
      this.stateService.getInitialState('', 'products').pipe(take(1)),
      /* LOGIN: */
      this.store$.select(UserState.isLoggedIn).pipe(
        pairwise(),
        filter(([wasLoggedIn, isLoggedIn]) => !wasLoggedIn && isLoggedIn),
        switchMap(() => this.stateService.getInitialState('', 'products').pipe(take(1)))
      )
    ).subscribe((products) => {
      dispatch(new InitShopProductsAction(products));
    });

    // Update products from server on entry update (name, attribute, instock, reservations)
    this.actions$.pipe(
      ofActionSuccessful(UpdateSectionEntryFromSyncAction),
      filter(action => {
        const actions = ['cartTitle', 'cartPrice', 'cartAttributes'];
        const prop = action.path.split('/').pop();
        return actions.indexOf(prop) > -1;
      }),
      switchMap(() => this.stateService.getInitialState('', 'products', true).pipe(take(1)))

    ).subscribe((products) => {
      dispatch(new InitShopProductsAction(products));
    });
  }
開發者ID:berta-cms,項目名稱:berta,代碼行數:27,代碼來源:shop-products.state.ts

示例3: ngOnInit

 ngOnInit() {
   this.store.select(UiState.currentLayer).subscribe(currentLayer => {
     this.currentLayer = currentLayer;
     if (currentLayer) {
       this.focusOnTreeNode(currentLayer);
     } else {
       this.treeControl.collapseAll();
     }
   });
 }
開發者ID:Julianhm9612,項目名稱:xlayers,代碼行數:10,代碼來源:tree-view.component.ts

示例4: ngxsOnInit

 ngxsOnInit() {
   this.store.select(ErrorState.getLastError)
     .pipe(filter(lastError => !!lastError))
     .subscribe((lastError: ErrorStateModel) => {
       this.popupService.showPopup({
         type: 'error',
         content: (lastError.httpStatus ? `${lastError.httpStatus}: ` : '') + lastError.message,
         timeout: 3000
       });
     });
 }
開發者ID:berta-cms,項目名稱:berta,代碼行數:11,代碼來源:error.state.ts

示例5: ngOnInit

 ngOnInit() {
   this.store.select(UiState.currentLayer).subscribe(currentLayer => {
     if (currentLayer) {
       this.componentStyle = (currentLayer as any).css as LayerCSS;
       this.computeBackgourndGradient();
     } else {
       this.componentStyle = null;
       this.gradients = [];
     }
   });
 }
開發者ID:Julianhm9612,項目名稱:xlayers,代碼行數:11,代碼來源:settings-layer-colors.component.ts

示例6: constructor

  constructor(private store: Store) {
    this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel, this.isExpandable, this.getChildren);
    this.treeControl = new FlatTreeControl<FileFlatNode>(this.getLevel, this.isExpandable);
    this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);

    this.store.select(UiState.currentPage).subscribe(currentPage => {
      if (currentPage) {
        this.dataSource.data = currentPage.layers;
      }
    });
  }
開發者ID:Julianhm9612,項目名稱:xlayers,代碼行數:11,代碼來源:tree-view.component.ts

示例7: ngxsOnInit

 ngxsOnInit({ dispatch }: StateContext<ShopRegionalCostsModel>) {
   return concat(
     this.stateService.getInitialState('', 'regionalCosts').pipe(take(1)),
     /* LOGIN: */
     this.store$.select(UserState.isLoggedIn).pipe(
       pairwise(),
       filter(([wasLoggedIn, isLoggedIn]) => !wasLoggedIn && isLoggedIn),
       switchMap(() => this.stateService.getInitialState('', 'regionalCosts').pipe(take(1)))
     )
   ).subscribe((regionalCosts) => {
     dispatch(new InitShopRegionalCostsAction(regionalCosts));
   });
 }
開發者ID:berta-cms,項目名稱:berta,代碼行數:13,代碼來源:shop-regional-costs.state.ts

示例8: canActivate

 canActivate(
   next: ActivatedRouteSnapshot,
   state: RouterStateSnapshot
 ): Observable<boolean> {
   return this.store.select(s => s.environement).pipe(
     map(env => env.uid),
     map(uid => !!uid),
     tap(hasUid => {
       if (!hasUid) {
         this.router.navigate(['/main/caption']);
       }
     })
   );
 }
開發者ID:chgc,項目名稱:stream-tools,代碼行數:14,代碼來源:editable.guard.ts

示例9: changePassword

 changePassword(oldPassword, newPassword) {
   return this.store.select(UserState).pipe(
     filter(user => !!user.token),
     take(1),
     switchMap(user => {
       return this.http.patch('/_api/v1/user/changepassword', {
           old_password: oldPassword,
           new_password: newPassword,
           retype_password: newPassword,
         },
         {
           headers: { 'X-Authorization': 'Bearer ' + user.token }
         }
       );
     })
   );
 }
開發者ID:berta-cms,項目名稱:berta,代碼行數:17,代碼來源:user.service.ts

示例10: ngxsOnInit

  ngxsOnInit({ dispatch }: StateContext<ShopSettingsModel>) {
    return concat(
      this.stateService.getInitialState('', 'settings').pipe(take(1)),
      /* LOGIN: */
      this.store$.select(UserState.isLoggedIn).pipe(
        pairwise(),
        filter(([wasLoggedIn, isLoggedIn]) => !wasLoggedIn && isLoggedIn),
        switchMap(() => this.stateService.getInitialState('', 'settings').pipe(take(1)))
      )
    ).subscribe((settings) => {
      const newState: {[k: string]: any} = {};

      for (const siteSlug in settings) {
        newState[siteSlug] = this.initializeShopSettingsForSite(settings[siteSlug]);
      }

      dispatch(new InitShopSettingsAction(newState));
    });
  }
開發者ID:berta-cms,項目名稱:berta,代碼行數:19,代碼來源:shop-settings.state.ts


注:本文中的@ngxs/store.Store.select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。