本文整理汇总了TypeScript中@ngxs/store.Action函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Action函数的具体用法?TypeScript Action怎么用?TypeScript Action使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Action函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: updateState
@Action(UpdateAppStateAction)
updateState({ patchState }: StateContext<AppStateModel>, action: UpdateAppStateAction) {
patchState(action.payload);
}
示例2: resetProducts
@Action(ResetShopSettingsAction)
resetProducts({ setState }: StateContext<ShopSettingsModel>) {
setState(defaultState);
}
示例3: loadData
@Action(LoadData)
public loadData({ patchState }: StateContext<TodoStateModel>) {
const data = { toppings: 'pineapple', crust: 'medium', extras: [false, false, true] };
return of(data).pipe(tap(values => patchState({ pizza: { model: { ...values } } })));
}
示例4: addSectionEntries
@Action(AddSectionEntriesAction)
addSectionEntries({ patchState, getState }: StateContext<SectionEntriesStateModel>, action: AddSectionEntriesAction) {
const state = getState();
patchState({[action.siteName]: [...state[action.siteName], ...action.entries]});
}
示例5: resetSectionEntries
@Action(ResetSectionEntriesAction)
resetSectionEntries({ setState }: StateContext<SectionEntriesStateModel>) {
setState({});
}
示例6: initializeShop
@Action(InitShopAction)
initializeShop({ setState }: StateContext<ShopModel>, action: InitShopAction) {
setState(action.payload);
}
示例7: imagesLoaded
@Action(ImagesLoaded)
imagesLoaded({ patchState }: StateContext<ExplorerImageStateModel>, action: ImagesLoaded) {
patchState({
images: action.images
});
}
示例8: resetSiteTemplates
@Action(ResetSiteTemplatesAction)
resetSiteTemplates({ setState }: StateContext<SiteTemplatesStateModel>) {
setState({});
}
示例9: addTodo
@Action(AddTodo)
public addTodo({ getState, setState }: StateContext<Todo[]>, { payload }: AddTodo) {
setState(state => [...state, payload]);
}
示例10: navigateBack
@Action(NavigateBack)
navigateBack({ getState, dispatch }: StateContext<ExplorerStateModel>) {
const state = getState();
state.currentPath.pop();
dispatch(new LoadContentByPath(state.currentPath));
}