1. 程式人生 > >[Recompose] Refactor React Render Props to Streaming Props with RxJS and Recompose

[Recompose] Refactor React Render Props to Streaming Props with RxJS and Recompose

handler round concept ping style nbsp tor migrate hid

This lesson takes the concept of render props and migrates it over to streaming props by keeping the same example and simple refactoring the Togglecomponent which handles the render prop.

const ToggleStream = componentFromStream(props$ => {
  const {
    handler: toggle,
    stream: toggle$
  } 
= createEventHandler() const on$ = Observable.merge( toggle$, Observable.interval(1000) ) .startWith(true) .scan(bool => !bool) return props$.combineLatest(on$, (props, on) => props.render({ on, toggle }) ) })

[Recompose] Refactor React Render Props to Streaming Props with RxJS and Recompose