Newer
Older
import {BaseStateModel} from "@app/base.state";
import {StateEnum} from "@app/shared/enums/state.enum";
import {GetAllLanguages} from "@app/shared/language.action";
import {LanguageState, LanguageStateModel} from "@app/shared/language.state";
import {GetAllLicenses} from "@app/shared/license.action";
import {LicenseState, LicenseStateModel} from "@app/shared/license.state";
import {GetAllResources, GetAllResourcesFail, GetAllResourcesSuccess} from "@app/shared/shared.action";
import {Action, State, StateContext} from "@ngxs/store";

Florent Poittevin
committed
export interface SharedStateModel extends BaseStateModel {
language: LanguageStateModel;
license: LicenseStateModel;
language: null,
license: null,
children: [
LanguageState,
LicenseState,
],
@Action(GetAllResources, {cancelUncompleted: true})
getAllResources(ctx: StateContext<SharedStateModel>, action: GetAllResources) {
ctx.dispatch([
new GetAllLanguages(),
new GetAllLicenses(),
new GetAllResourcesSuccess(), // TO FIX Should be raised only when GetAllLanguagesSuccess and GetAllLicensesSuccess is raised)
]);
@Action(GetAllResourcesSuccess)
getAllResourcesSuccess(ctx: StateContext<SharedStateModel>, action: GetAllResourcesSuccess) {
@Action(GetAllResourcesFail)
getAllResourcesFail(ctx: StateContext<SharedStateModel>) {
ctx.patchState({
isLoading: false,
});
}
}