angular-redux / store

Angular 2+ bindings for Redux
MIT License
1.34k stars 205 forks source link

How to detect when a dispatched action completes ? #543

Open melkishengue opened 5 years ago

melkishengue commented 5 years ago

This is a...

What toolchain are you using for transpilation/bundling?

Environment

NodeJS Version: v8.11.2 Typescript Version: Angular Version: 6 @angular-redux/store version: 9.0.0 @angular/cli version: (if applicable) 6.0.8 OS: OSX

Additional Notes:

I would just like to know if it is possible to detect when an action completes, when using angular-redux. May be something like returning a promise... If yes, a small example will help a lot. Thanks in advance.

gregkopp commented 5 years ago

Whatever is acting on your action (in an Epic, I would assume) should dispatch another action indicating such.

ie.: Dispatch: DATA_REQUESTED Epic: Calls API and gets data Dispatch: DATA_RECEIVED

Your DAT_RECEIVED action can then be handled in your reducer. I have used this method in the past for busy indicators.