当前位置: 首页>>代码示例>>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;未经允许,请勿转载。