Skip to content

Instantly share code, notes, and snippets.

@geowarin
Last active July 20, 2016 13:59
Show Gist options
  • Save geowarin/c35f8a00e1deb36f0880763d1f6291ef to your computer and use it in GitHub Desktop.
Save geowarin/c35f8a00e1deb36f0880763d1f6291ef to your computer and use it in GitHub Desktop.
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}
])
});
@sebald
Copy link

sebald commented Jul 19, 2016

Super curious of how the internals of this are working. Is it create as an ArrayLikeObservable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment