import * as React from 'react' import {Observable} from 'rxjs' import {map} from 'rxjs/operators' import {streamingComponent} from './streamingComponent' type ObservableFactory = (( props$: Observable ) => Observable) export function withPropsStream( observableOrFactory: Observable | ObservableFactory, TargetComponent: React.ComponentType ) { const ComposedComponent = streamingComponent(sourceProps$ => { const targetProps$ = typeof observableOrFactory === 'function' ? observableOrFactory(sourceProps$) : observableOrFactory return targetProps$.pipe(map(props => )) }) const displayName = typeof TargetComponent === 'string' ? TargetComponent : TargetComponent.displayName || (TargetComponent as any).name || 'Component' ComposedComponent.displayName = `withPropsStream(${displayName})` return ComposedComponent }