Skip to content

Instantly share code, notes, and snippets.

@oakfang
Created March 6, 2016 06:36
Show Gist options
  • Select an option

  • Save oakfang/549a51451d2362466ec8 to your computer and use it in GitHub Desktop.

Select an option

Save oakfang/549a51451d2362466ec8 to your computer and use it in GitHub Desktop.
Exrtact s State Stream from a redux store
import { BehaviourSubject } from 'rx';
export function getStateStream(store) {
const sub = new BehaviourSubject(store.getState());
store.subscribe(state => sub.toNext(sub));
return sub.asObservable();
}
@b2whats
Copy link

b2whats commented May 15, 2016

new redux

import Rx from 'rxjs'
import $$observable from 'symbol-observable'

export default function observableFromStore(store) {
  const store$ = new Rx.BehaviorSubject(store.getState())

  const observableSubscribe = store[$$observable]()
  observableSubscribe.subscribe(store$)

  return store$
}

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