Last active
July 20, 2016 13:59
-
-
Save geowarin/c35f8a00e1deb36f0880763d1f6291ef to your computer and use it in GitHub Desktop.
This file contains 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 test from 'ava'; | |
import Rx from 'rxjs/Rx'; | |
import {createStore} from 'redux'; | |
test('should be observable', t => { | |
const reducer = (state, action) => { | |
if (action.type === 'increment') { | |
return {...state, counter: state.counter + 1} | |
} | |
return state; | |
}; | |
const store = createStore(reducer, {counter: 0}); | |
const results = []; | |
Rx.Observable.from(store) | |
.distinct() | |
.subscribe(state => results.push(state)); | |
store.dispatch({type: 'increment'}); | |
store.dispatch({type: 'unknown'}); | |
store.dispatch({type: 'increment'}); | |
t.deepEqual(results, [ | |
{counter: 0}, | |
{counter: 1}, | |
{counter: 2} | |
]) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Super curious of how the internals of this are working. Is it create as an
ArrayLikeObservable
?