當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。