码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2017-12-28 12:00:49      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:nbsp   round   actor   latest   rate   stream   which   event   width   

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

标签:nbsp   round   actor   latest   rate   stream   which   event   width   

原文地址:https://www.cnblogs.com/Answer1215/p/8131606.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!