• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript store.Actions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@ngxs/store.Actions的典型用法代码示例。如果您正苦于以下问题:TypeScript Actions类的具体用法?TypeScript Actions怎么用?TypeScript Actions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Actions类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

    it('should dispatch CredentialsExpiredAction when credentials have expired or are invalid (401)', () => {
        const errorResponse = new HttpErrorResponse({
            status: 401,
            error: {
                error: 'expired/invalid'
            },
            statusText: '401 Unauthenticated'
        });

        const route = '/api/error401';
        client.get(route).subscribe(
            (response) => {
                expect(response).toBeFalsy();
            },
            (error) => {
                expect(error).toBeTruthy();
                expect(error.error).toBe('expired/invalid');
            }
        );

        actions.pipe(ofActionDispatched(CredentialsExpiredAction)).subscribe((payload: any) => {
            expect(payload).toBeTruthy();
            expect(payload instanceof CredentialsExpiredAction).toBe(true);
        });

        backend.expectOne(route).flush({}, errorResponse);

        expect(toastrSpy).toHaveBeenCalledTimes(0);
    });
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:29,代码来源:error.interceptor.spec.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: handleUntrackedImage

 handleUntrackedImage(image: IMergedImageDto) {
   this.store.dispatch(new CreateImageByPath(image.absolutePath, image.name, image.extension));
   this.actions$.pipe(
     ofActionSuccessful(ImageCreated),
     first()
   ).subscribe((action: ImageCreated) => {
     this.toastr.success(`Bild "${action.createdImage.name}.${action.createdImage.extension}" hinzugefĂźgt`);
   });
 }
开发者ID:pschild,项目名称:image-management-tool,代码行数:9,代码来源:explorer.component.ts


示例4: handleUntrackedFolder

 handleUntrackedFolder(folder: IMergedFolderDto) {
   this.store.dispatch(new CreateFolderByPath(folder.absolutePath));
   this.actions$.pipe(
     ofActionSuccessful(FolderCreated),
     first()
   ).subscribe((action: FolderCreated) => {
     this.toastr.success(`Ordner "${action.createdFolder.name}" hinzugefĂźgt`);
   });
 }
开发者ID:pschild,项目名称:image-management-tool,代码行数:9,代码来源:explorer.component.ts


示例5: ngxsOnInit

 ngxsOnInit({ dispatch }: StateContext<SectionTagsStateModel>) {
   concat(
     this.appStateService.getInitialState('', 'section_tags').pipe(take(1)),
     this.actions$.pipe(ofActionSuccessful(UserLoginAction), switchMap(() => {
       return this.appStateService.getInitialState('', 'section_tags').pipe(take(1));
     }))
   )
   .subscribe((sectionTags) => {
     dispatch(new InitSiteSectionsTagsAction(sectionTags));
   });
 }
开发者ID:berta-cms,项目名称:berta,代码行数:11,代码来源:section-tags.state.ts


示例6: ngxsOnInit

 ngxsOnInit({ dispatch }: StateContext<SitesSettingsStateModel>) {
   concat(
     this.appStateService.getInitialState('', 'site_settings').pipe(take(1)),
     this.actions$.pipe(ofActionSuccessful(UserLoginAction), switchMap(() => {
       return this.appStateService.getInitialState('', 'site_settings').pipe(take(1));
     }))
   )
   .subscribe({
     next: (response: SiteSettingsResponse) => {
       dispatch(new InitSiteSettingsAction(response));
     },
     error: (error) => console.error(error)
   });
 }
开发者ID:berta-cms,项目名称:berta,代码行数:14,代码来源:site-settings.state.ts


示例7: ngxsOnInit

  ngxsOnInit({ getState, dispatch }: StateContext<AppStateModel>) {
    this.router.events.pipe(
      filter(evt => evt instanceof ActivationEnd)
    ).subscribe((event: ActivationEnd) => {
      const state = {...getState()};
      const newSiteName = event.snapshot.queryParams['site'] || '';
      const newSectionName = !event.snapshot.queryParams['section'] ? null : event.snapshot.queryParams['section'];

      // Set current site and section
      if (state.site !== newSiteName || state.section !== newSectionName) {
        dispatch(new UpdateAppStateAction({site: newSiteName, section: newSectionName}));
      }
    });

    this.router.events.pipe(
      filter(event => event instanceof NavigationEnd),
      map((event: NavigationEnd) => event.url.split('?')[0]),
      filter(url => url !== '/' && url !== '/login')
    ).subscribe((url: string) => {
      dispatch(new UpdateAppStateAction({lastRoute: url}));
    });

    this.appStateService.getAppMetadata().pipe(take(1))
      .subscribe({
        next: (metadata) => {
          dispatch(new UpdateAppStateAction(metadata));
        },
        error: (error) => console.error(error)
      });

    concat(
      this.appStateService.getInitialState('').pipe(take(1)),
      // After each subsequent successful login, initialize the state
      this.actions$.pipe(
        ofActionSuccessful(UserLoginAction),
        switchMap(() => this.appStateService.getInitialState('').pipe(take(1)))
      )
    )
    .subscribe({
      next: (response) => {
        dispatch(new InitAppStateAction({urls: response.urls}));
      },
      error: (error) => console.error(error)
    });
  }
开发者ID:berta-cms,项目名称:berta,代码行数:45,代码来源:app.state.ts


示例8: connectIframeReload

  connectIframeReload(iframe: HTMLIFrameElement) {
    /*
      Catch external links and prevent navigating away from iframe
    */
    this.catchExternalLinks(iframe.contentWindow.document);

    /*
      Reload the preview iframe after settings affecting preview change
      Because we don't have preview renderer in frontend yet.
     */
    this.iframeReloadSubscription = this.actions$.pipe(
      ofActionSuccessful(
        ...[
          CreateSiteAction,
          UpdateSiteAction,
          ReOrderSitesAction,
          DeleteSiteAction,
          AddSiteSectionsAction,
          UpdateSiteSectionAction,
          RenameSiteSectionAction,
          ReOrderSiteSectionsAction,
          DeleteSiteSectionAction,
          DeleteSiteSectionsAction,
          UpdateSiteSettingsAction,
          UpdateSiteTemplateSettingsAction
        ]
      ),
      /* Only reload when the overlay gets closed: */
      buffer(this.store.select(AppState.getShowOverlay).pipe(
        scan(([_, prevShowOverlay]: [boolean, boolean], showOverlay: boolean) => {
          return [prevShowOverlay, showOverlay];
        }, [false, false]),
        filter(([prev, cur]) => prev !== cur && !cur)
      )),
      filter(actionsPassed => actionsPassed.length > 0),
    ).subscribe(() => {
      iframe.contentWindow.location.reload();
    });
  }
开发者ID:berta-cms,项目名称:berta,代码行数:39,代码来源:preview.service.ts


示例9: ngxsOnInit

  ngxsOnInit({ dispatch }: StateContext<SiteSettingsConfigStateModel>) {
    concat(
      this.appStateService.getInitialState('', 'siteSettingsConfig').pipe(take(1)),
      this.actions$.pipe(ofActionSuccessful(UserLoginAction), switchMap(() => {
        return this.appStateService.getInitialState('', 'siteSettingsConfig').pipe(take(1));
      }))
    )
    .subscribe({
      next: (siteSettingsConfig: SiteSettingsConfigResponse) => {
        dispatch(new InitSiteSettingsConfigAction(siteSettingsConfig));
      },
      error: (error) => console.error(error)
    });

    // Listen for language change
    this.store.select(SiteSettingsState.getCurrentSiteLanguage).pipe(
      pairwise(),
      filter(([prevLang, lang]) => !!prevLang && !!lang && prevLang !== lang),
      switchMap(([, language]) => this.appStateService.getLocaleSettings(language, 'siteSettingsConfig').pipe(take(1)))
    ).subscribe((siteSettingsConfig: SiteSettingsConfigResponse) => {
      dispatch(new InitSiteSettingsConfigAction(siteSettingsConfig));
    });
  }
开发者ID:berta-cms,项目名称:berta,代码行数:23,代码来源:site-settings-config.state.ts



注:本文中的@ngxs/store.Actions类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript store.NgxsModule类代码示例发布时间:2022-05-28
下一篇:
TypeScript store.ofActionSuccessful函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap