Last active
December 19, 2016 22:45
-
-
Save nickbalestra/2ad4c764ae1e975849937f1c3de84b1f to your computer and use it in GitHub Desktop.
Creates stream of states from a Redux store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import xs from 'xstream' | |
| function streamFromStore(store) { | |
| return xs.create( | |
| { | |
| start: function(listener){ | |
| this.unsubscribe = store.subscribe(() => listener.next(store.getState())) | |
| }, | |
| stop: function(){ | |
| this.unsubscribe() | |
| } | |
| } | |
| ).startWith(store.getState()) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment