This lesson takes the concept of render props and migrates it over to streaming props by keeping the same example and simple refactoring the Toggle
component 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 }) ) })
原文地址:https://www.cnblogs.com/Answer1215/p/8131606.html
时间: 2024-10-26 06:26:43