本文整理汇总了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)
]);
}
});
示例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('');
});
示例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(['/']));
}
}
示例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(
示例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);
});
});
示例6: switchMap
switchMap(() => {
return this.store.dispatch(new DeleteSectionEntryFromSyncAction(
data.site,
data.section,
data.entryId
));
}),
示例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));
}
示例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.');
}
}
示例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`);
});
}
示例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`);
});
}