本文整理匯總了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`);
});
}