fxstore
v0.2.0
Published
Fx store is a flux framework to manage store state in Angular
Downloads
4
Readme
Creating commands and store state example
import { Command, ReducerCommand, State } from './command';
@State()
class Store1State {
public IsLoading: boolean;
public IsBusy: boolean;
public Value: string;
public initialize() {
this.IsLoading = false;
this.IsBusy = false;
this.Value = '';
return this;
}
}
@Command(Store1State)
class IsLoadingCommand extends ReducerCommand<Store1State, any> {
public Handle() {
this.State.IsLoading = true;
}
}
@Command(Store1State)
class IsBusyCommand extends ReducerCommand<Store1State, any> {
public Handle() {
this.State.IsBusy = true;
}
}
@Command(Store1State)
class SetValueCommand extends ReducerCommand<Store1State, string> {
public Handle() {
this.State.Value = this.Payload;
}
}
Dispatch a command example
const isLoadingCommand = new IsLoadingCommand();
isLoadingCommand.Dispatch();
const setValueCommand = new SetValueCommand();
setValueCommand.Dispatch('My new value');
Create a selector example
const o = createSelector<Store1State>(x => x.IsLoading, Store1State.name);