src/reactiveComponent.js
function makeReactive(componentDefinition, renderFn, ...stateStreamNames) {
  class ReactiveComponent extends PureComponent {
    constructor(props, context) {
      super(props, context);
      this.state = { childProps: {} }
      this.omnistream = this.context.omnistream;

      // Make the dispatch function accessible to be passed as a prop to child components.
      this.dispatch = this.omnistream.dispatch.bind(context.omnistream);
      this.dispatchObservableFn = this.omnistream.dispatchObservableFn.bind(context.omnistream);
    }

    componentDidMount() {
      // Creates a new substream for each action type based on the provided "streamNames"
      const stateStreams = stateStreamNames.map(name => this.omnistream.store[name]);
      const state$ = combineStreamsToState(stateStreams);
      // Subscribes to the props stream. This will trigger a re-render whenever a new action has been dispatched to 
      // any filtered stream passed down as props to a component.
      this.subscription = state$.subscribe((props) => {
        this.setState({ childProps: Object.assign({}, this.props, props) });
      });
    }

    componentWillUnmount() {
      this.subscription.unsubscribe();
    }

    render() {
      return renderFn.call(this, componentDefinition);
    }
  }
  ReactiveComponent.contextTypes = { omnistream: React.PropTypes.object.isRequired }
  return ReactiveComponent;
}
function makeReactive(componentDefinition, renderFn, ...stateStreamNames) {
  class ReactiveComponent extends PureComponent {
    constructor(props, context) {
      super(props, context);
      this.state = { childProps: {} }
      this.omnistream = this.context.omnistream;

      // Make the dispatch function accessible to be passed as a prop to child components.
      this.dispatch = this.omnistream.dispatch.bind(context.omnistream);
      this.dispatchObservableFn = this.omnistream.dispatchObservableFn.bind(context.omnistream);
    }

    componentDidMount() {
      // Creates a new substream for each action type based on the provided "streamNames"
      const stateStreams = stateStreamNames.map(name => this.omnistream.store[name]);
      const state$ = combineStreamsToState(stateStreams);
      // Subscribes to the props stream. This will trigger a re-render whenever a new action has been dispatched to 
      // any filtered stream passed down as props to a component.
      this.subscription = state$.subscribe((props) => {
        this.setState({ childProps: Object.assign({}, this.props, props) });
      });
    }

    componentWillUnmount() {
      this.subscription.unsubscribe();
    }

    render() {
      return renderFn.call(this, componentDefinition);
    }
  }
  ReactiveComponent.contextTypes = { omnistream: React.PropTypes.object.isRequired }
  return ReactiveComponent;
}
function makeReactive ( componentDefinition , renderFn , ... stateStreamNames ) { class ReactiveComponent extends PureComponent { constructor ( props , context ) { super ( props , context ) ; this . state = { childProps : { } } this . omnistream = this . context . omnistream ; // Make the dispatch function accessible to be passed as a prop to child components. this . dispatch = this . omnistream . dispatch . bind ( context . omnistream ) ; this . dispatchObservableFn = this . omnistream . dispatchObservableFn . bind ( context . omnistream ) ; } componentDidMount ( ) { // Creates a new substream for each action type based on the provided "streamNames" const stateStreams = stateStreamNames . map ( name => this . omnistream . store [ name ] ) ; const state$ = combineStreamsToState ( stateStreams ) ; // Subscribes to the props stream. This will trigger a re-render whenever a new action has been dispatched to  // any filtered stream passed down as props to a component. this . subscription = state$ . subscribe ( ( props ) => { this . setState ( { childProps : Object . assign ( { } , this . props , props ) } ) ; } ) ; } componentWillUnmount ( ) { this . subscription . unsubscribe ( ) ; } render ( ) { return renderFn . call ( this , componentDefinition ) ; } } ReactiveComponent . contextTypes = { omnistream : React . PropTypes . object . isRequired } return ReactiveComponent ; }
ReactiveComponent subscribes to a stream and re-renders when it receives new data.
ReactiveComponent subscribes to a stream and re - renders when it receives new data .