zoukankan      html  css  js  c++  java
  • [Recompose] Refactor React Render Props to Streaming Props with RxJS and Recompose

    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
        })
      )
    })

  • 相关阅读:
    树:二叉树
    树:红黑树
    gtest
    VDB R&D
    QML 从入门到放弃
    json parse
    Effective C++ 笔记
    Samples topic
    C++ 11 snippets , 2
    C++ 11 snippets , 1
  • 原文地址:https://www.cnblogs.com/Answer1215/p/8131606.html
Copyright © 2011-2022 走看看