0.0.2 • Published 6 years ago
@nju33/reducer-action v0.0.2
ReducerAction
Install
yarn add -D @nju33/reducer-action
Example
import {ReducerAction} from '@nju33/reducer-action';
const enum ActionType {
A,
B,
}
const action = {
a() {
return {
type: ActionType.A as ActionType.A,
payload: {
foo: 'foo',
},
};
},
b() {
return {
type: ActionType.B as ActionType.B,
payload: {
bar: 'bar',
},
};
},
};
type Action = ReducerAction<typeof action>;
const aAction: Action = action.a() as any;
switch (aAction.type) {
case ActionType.A: {
aAction.payload.foo;
break;
}
case ActionType.B: {
aAction.payload.bar;
break;
}
default:
}