Why I Like redux-observable

I would like to share my experience with redux-observable in a few points.

Logic separation

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.

Easy invocation

Epics react on redux actions, so everywhere you can invoke it, epics listen.

Declarative style

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 :).

Promise cancelation

Redux-observable can cancel promise if there is newer version of same call. It’s very handy for suggestion lists via API for example.

DEMO time

redux-observable epic example from app Prace za Rohem

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.

Cons

  • 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 :/

Resources

Thanks for reading!

--

--

--

I'm react-native and iOS developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to convert CSV to JSON in C# .NET Framework, Node.JS

Implementing DART SASS in REACT

IONIC — Offline map using satellite images with leaflet JS

How to Convert CSV to XML in JavaScript

UI Button Navigation without Code

How to Extract Macro Information from a Word file in Node.JS

How to trim leading and trailing Whitespace from a Text String in Node.JS

How to Upgrade Angular Version in Existing Angular Project

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Petr Lzicar

Petr Lzicar

I'm react-native and iOS developer

More from Medium

A Cure to Rerendering: Redux with Containers

How to fix “RNCSafeAreaProvider” was not found in the UIManager Error

Hookstate Performance: Subscribing to single items in a collection

Higher Order Component for listing data using FlatList in React Native