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