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


TypeScript Store.dispatch方法代码示例

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


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

示例1: RenameShopRegionSiteAction

 ).subscribe(([oldSiteName, newSiteName]) => {
   /**
    * @note: Orders and Products don't need to be initialized, because there will be no orders or products
    * for site that's just created
    */
   if (oldSiteName && newSiteName) {
     this.store$.dispatch([
       new RenameShopRegionSiteAction(oldSiteName, newSiteName),
       new RenameShopSettingsSiteAction(oldSiteName, newSiteName),
       new RenameShopProductSiteAction(oldSiteName, newSiteName),
       new RenameShopOrdersSiteAction(oldSiteName, newSiteName)
     ]);
   } else if (oldSiteName) {
     // Site was deleted - delete settings for the site
     this.store$.dispatch([
       new DeleteShopRegionSiteAction(oldSiteName),
       new DeleteShopSettingsSiteAction(oldSiteName),
       new DeleteShopProductSiteAction(oldSiteName),
       new DeleteShopOrdersSiteAction(oldSiteName)
     ]);
   } else if (newSiteName) {
     // Site was created - get the data from server
     this.store$.dispatch([
       new AddShopRegionSiteAction(newSiteName),
       new AddShopSettingsSiteAction(newSiteName),
       new AddShopProductSiteAction(newSiteName),
       new AddShopOrdersSiteAction(newSiteName)
     ]);
   }
 });
开发者ID:berta-cms,项目名称:berta,代码行数:30,代码来源:shop.state.ts

示例2: it

        it('should handle logout', () => {
            const credentials = new UserCredentials('my-user', 'my-pass');
            const user = new AuthenticatedUser(credentials.username, 'testing-token', [
                new UserAuthority('AUTH_1'),
                new UserAuthority('AUTH_2'),
                new UserAuthority('AUTH_3')
            ]);
            store.dispatch(new LoginAction(credentials));

            const testResponse = {
                token: user.token,
                authorities: user.authorities.map(val => val.name)
            };
            const request = backend.expectOne(`/api/login`);
            request.flush(testResponse);
            backend.verify();

            store.dispatch(new LogoutAction());

            store.selectOnce(SessionState).subscribe(state => {
                expect(state).toBeTruthy();
                expect(state).toBe(defaultSessionState);
            });

            expect(location.path()).toBe('');
        });
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:26,代码来源:session.state.spec.ts

示例3: logout

 @Action(LogoutAction)
 logout(ctx: StateContext<SessionStateModel>) {
     if (ctx.getState().state === 'authenticated') {
         ctx.setState(defaultSessionState);
         localStorage.setItem('session', JSON.stringify(defaultSessionState));
         this.store.dispatch(new HideSideNavAction());
         this.store.dispatch(new Navigate(['/']));
     }
 }
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:9,代码来源:session.state.ts

示例4: AppHideLoading

 return Observable.create(observer => {
   this.store.dispatch(new AppHideLoading());
   this.popupService.showPopup({
     type: 'warn',
     content: 'Are you sure you want to delete this entry?',
     showOverlay: true,
     isModal: true,
     actions: [
       {
         type: 'primary',
         label: 'OK',
         callback: (popupService) => {
           observer.next();
           observer.complete();
           popupService.closePopup();
         }
       },
       {
         label: 'Cancel',
         callback: (popupService) => {
           observer.complete();
           popupService.closePopup();
         }
       }
     ],
   });
 }).pipe(
开发者ID:berta-cms,项目名称:berta,代码行数:27,代码来源:preview.service.ts

示例5: it

 it('it should set location', () => {
   store.dispatch(new SetLocation({ latitude: 10, longitude: 10 }));
   store.selectOnce(state => state.filter.location).subscribe(location => {
     expect(location.latitude).toBe(10);
     expect(location.longitude).toBe(10);
   });
 });
开发者ID:estrellajm,项目名称:itinerary,代码行数:7,代码来源:filter.state.spec.ts

示例6: switchMap

 switchMap(() => {
   return this.store.dispatch(new DeleteSectionEntryFromSyncAction(
     data.site,
     data.section,
     data.entryId
   ));
 }),
开发者ID:berta-cms,项目名称:berta,代码行数:7,代码来源:preview.service.ts

示例7: onDrop

  onDrop(event: CdkDragDrop<string[]>) {
    if (event.previousIndex === event.currentIndex) {
      return;
    }

    moveItemInArray(this.sectionsList, event.previousIndex, event.currentIndex);
    this.store.dispatch(new ReOrderSiteSectionsAction(event.previousIndex, event.currentIndex));
  }
开发者ID:berta-cms,项目名称:berta,代码行数:8,代码来源:site-sections.component.ts

示例8: onFileSelected

 async onFileSelected(file: File) {
   try {
     this.data = await this.service.process(file);
     this.store.dispatch(new CurrentFile(this.data));
   } catch (e) {
     console.error(e);
     // alert('Only .sketch files that were saved using Sketch v43 and above are supported.');
   }
 }
开发者ID:Julianhm9612,项目名称:xlayers,代码行数:9,代码来源:sketch-container.component.ts

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

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


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