Why I Like redux-observable
I would like to share my experience with redux-observable in a few points.
Epics is nice place for your business logic. Doesn’t matter which functionality you need handle. Epics can contains almost everything — Api calls, Navigation handling, or other side-effects.
Epics react on redux actions, so everywhere you can invoke it, epics listen.
Declarative style of writing is good readable and clean. On first view you know what code really do and don’t have guess in most cases :).
Redux-observable can cancel promise if there is newer version of same call. It’s very handy for suggestion lists via API for example.
As you can see on image above, we have epic for events logging. Everytime when LOG_EVENT action is triggered this epic react on it. In short do this: skipe execution when logging is disabled, create a buffer if there is more events, because want to save some network resources and want to send more data at once. After buffer time exceed, will send to our API all captured events and fail silently when needed.
- Easy to break — if you forgot close stream for example
- Lots of extra code writing — need epic, connect epic, epic middleware, need redux-action, need connect redux to Components…
- Project is now in maintanance mode :/
Thanks for reading!