1.1.1 • Published 6 years ago
typescript-actions v1.1.1
typescript-actions
Typescript actions/reducers based on classes
Installation
// NPM
npm install --save typescript-actions
// YARN
yarn add typescript-actionsModify .tsconfig
{
"compilerOptions": {
...
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
...
}
}Add simple store
import {action, ActionBase, apiAction, nameof, PromiseOrVoid} from 'typescript-actions/dist';
export interface ICounterStore extends IStoreBase {
result: number;
}
export const initialCounterStore: ICounterStore = {
...baseInitialStore,
result: 0,
};Action example
import {action, ActionBase, apiAction, nameof, PromiseOrVoid} from 'typescript-actions/dist';
export interface ICounterActions {
increment(): void;
decrement(): void;
}
export class CounterActions extends ActionBase implements ICounterActions {
@action()
public increment(): void {
this.dispatch({
name: this.actionName,
payload: null
});
}
@action()
public decrement(): void {
this.dispatch({
name: this.actionName,
payload: null
});
}
public getStoreName(): string {
return nameof<IGlobalStore>('counter') as string;
}
}Reducer example
import {ReducerBase} from 'typescript-actions/dist';
export class CounterReducer extends ReducerBase<ICounterStore> implements ICounterActions {
public getStoreName() {
return nameof<IGlobalStore>('counter');
}
@reducer()
public increment(): void {
this.setState({
result: this.store.result + 1
});
}
@reducer()
public decrement(): void {
this.setState({
result: this.store.result - 1
});
}
}1.1.1
6 years ago
1.0.78
6 years ago
1.0.77
6 years ago
1.0.76
6 years ago
1.0.75
6 years ago
1.0.74
6 years ago
1.0.73
6 years ago
1.0.72
7 years ago
1.0.71
7 years ago
1.0.70
7 years ago
1.0.69
7 years ago
1.0.68
7 years ago
1.0.67
7 years ago
1.0.66
7 years ago
1.0.65
7 years ago
1.0.64
7 years ago
1.0.63
7 years ago
1.0.62
7 years ago
1.0.61
7 years ago
1.0.60
7 years ago
1.0.59
7 years ago
1.0.58
7 years ago
1.0.57
7 years ago
1.0.56
7 years ago
1.0.55
7 years ago
1.0.54
7 years ago
1.0.53
7 years ago
1.0.52
7 years ago
1.0.51
7 years ago
1.0.50
7 years ago
1.0.49
7 years ago
1.0.48
7 years ago
1.0.47
7 years ago
1.0.46
7 years ago
1.0.45
7 years ago
1.0.44
7 years ago
1.0.43
7 years ago
1.0.42
7 years ago
1.0.41
7 years ago
1.0.40
7 years ago
1.0.39
7 years ago
1.0.35
7 years ago
1.0.32
7 years ago
1.0.30
7 years ago
1.0.29
7 years ago
1.0.27
7 years ago
1.0.12
7 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago