-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I know class is "blee" but I like when an action is class
In this implementation, you can add payload's interface for any action
export class IncrementCounter implements Action {
readonly type = INCREMENT;
constructor(public payload: any) {}
}
export class DecrementCounter implements Action {
readonly type = DECREMENT;
constructor(public payload: any) {}
}
export type CounterActions =
IncrementCounter
| DecrementCounter;
👍
vs
function newAction(type: string) {
return (payload?: any): CounterAction => ({ payload, type });
}
export const incrementCounter: () => CounterAction = newAction(INCREMENT);
export const decrementCounter: () => CounterAction = newAction(DECREMENT);
❤️
miroslaw-bogaczdakolech and dbachorz
Metadata
Metadata
Assignees
Labels
No labels