[Recompose] Compose Streams of React Props with Recompose’s compose and RxJS

Functions created with mapPropsStream canned be composed together to build up powerful streams. Bring in the compose helper from Recompose then simply list your functions in the order you want the props to push through.

 In the example, we compose three things together, in order to create a powerful component.

1. We map user's click event to on increate and on decrease event streams.

2. We foward those count props to next stream 'loading', it will call ajax api to get Star Wars heros.

3. Last we create a typewriter to get a typing effect,

const CounterWithPersonLoader = compose(
  count,
  load,
  typewriter
)(Counter)

 

 

 

 

posted @ 2017-12-27 20:03  Zhentiw  阅读(251)  评论(0编辑  收藏  举报