Prevent or warn when an action class is used multiple times in a store
tfriem opened this issue · comments
Tobias Friemel commented
When an action class is used in multiple action decorators on the same store, only one of the decorated methods is being called for this action. While the limitation itself makes sense, an error or warning would make it easier to detect bugs related to this.
Example:
@Store({
})
export class ExampleStore {
@Action(ExampleAction)
load(state: AppState, action: ExampleAction) {
alert('Message 1');
}
@Action(ExampleAction)
load(state: AppState, action: ExampleAction) {
alert('Message 2');
}
}
Only "Message 2" will be shown when ExampleAction
is dispatched.
My experience with decorators in Typescript is limited, but if it's okay, I would try myself on a PR for this.
Austin commented
Absolutely. The check would somewhere around here - https://github.com/amcdnl/ngrx-actions/blob/master/src/action.ts#L12