useActions
A facade is literally a data structure that bundles actions and case-reducers together. However, sometimes it is needed to only have the plain actions that can be used outside the context of the facade. Threfore, getActions
has been created.
Extract actions
You need plain action-creators in NgRx's effects. To use the action-creators from the facade you just need to use getActions
and pass the class token of the Facade to it. This gives you vanilla NgRx action creators that can be used in the effect (see effect.ts
).
Prefix action
You pass a configuration to useActions
containing a prefix that should be set before each action type.
Inlining
Currently, inlining useActions
is not possible due to a breaking change in TyepScript and ES2022-Module.
If you already use inlining, please read migrations/v15 to learn how to resolve this issue.
You also can inline getActions
in your Facade holding everything together. It's up to you which style you prefer. The benefit of inlining is, that the Facade becomes the only thing you import somewhere else.
Last updated