import { Action, Selector, State, StateContext } from '@ngxs/store';

export interface GenEventMapPickerStateModel {
    isLoading: boolean
}

const initialStateModel: GenEventMapPickerStateModel = {
    isLoading: false
};

export class SetIsLoading {
    static readonly type = '[GenEventMapPicker] set Loading';
    constructor(public val: boolean) {
    }
}

@State<GenEventMapPickerStateModel>({
    name: 'genEventMapPicker',
    defaults: initialStateModel
})
export class GenEventMapPickerState {

    @Selector()
    static isLoading(state: GenEventMapPickerStateModel) {
        return state.isLoading;
    }

    @Action(SetIsLoading)
    setLoading(ctx: StateContext<GenEventMapPickerStateModel>,
        { val }: SetIsLoading) {
        ctx.patchState({
            isLoading: val
        })
    }

}
