useActions
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
You need plain action-creators in . 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
).
You pass a configuration to useActions
containing a prefix that should be set before each action type.
Currently, inlining useActions
is not possible due to a breaking change in TyepScript and ES2022-Module.
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.
If you already use inlining, please read to learn how to resolve this issue.