当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript store.ofActionSuccessful函数代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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.ofActionSuccessful函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。