ngrx-domains
ngrx-domains copied to clipboard
Questions on examples and weak typing
Thanks for putting this together. It really fits a need we have.
I noticed your examples do not enforce strong typing of reducer() arguments. The action is passed in as 'any'.
I'm also not clear on the switch on action.constructor instead of action.type.
Is this an oversight, a simplification, or a limitation?
I am also a bit confused by the README's Actions.ts and reducer.ts which define/consume actions and action types differently from your source examples. I'm fairly new to typescript and especially extending types, so I apologize if this is an obvious question.
Thanks.
I noticed your examples do not enforce strong typing of reducer() arguments. The action is passed in as 'any'.
You can change the way actions are handled, you can make it 1 class with actions as methods...
This is just an example trying to stay close to the example-app
in ngrx
I'm also not clear on the switch on action.constructor instead of action.type.
Again, just an implementation.
Every action has it's own class so action
is an instance of that class which means action.constructor
is the class and that comparison is much faster then string comparison.
I agree it's risky and requires some rules to be set about creating and using actions... again just a demo.
I am also a bit confused by the README's Actions.ts and reducer.ts which define/consume actions and action types differently from your source examples. I'm fairly new to typescript and especially extending types, so I apologize if this is an obvious question.
Same thing, you can change the implementation the library does not tell you how to define or consume actions or reducers.