This example implements the chat-app example from Horizon.io with Redux and redux-saga.
This example is pretty over-engineered for a tiny chat app, but I wanted to structure it how I would a real Redux app. For a quick view of how the Horizon/redux-saga relationship works, jump over to app/chat/sagas/watchMessages.js. It's pretty straight-forward: you just create a redux-saga eventChannel that subscribes to a Horizon query Observable as its event source, and then have a saga take()
that channel and respond to its events accordingly.
(You'll need to have Horizon installed first)
git clone [email protected]:shanecav/horizon-redux-saga.git
cd horizon-redux-saga && npm install
hz init
hz serve --dev
- In a new terminal in the same directory:
npm start
If you're looking for a simpler alternative that doesn't depend on redux-saga, you might want to check out my horizon-redux library. It's not as powerful as redux-saga, but it's a lot smaller and easier to implement (in my opinion) if your needs are basic.
You can also check out redux-observable if RxJS is more your thing - Horizon should integrate really well with it since Collections are RxJS Observables.
If you have any problems running this example, or have some suggestions, open an issue and I'll respond pretty quickly. Thanks!