Example #1
0
const mapToProps = (props$: Observable<PropsInType>): Observable<PropsOutType> => {
    const storeApi = new StoreApi();
    const input$ = new Subject();

    const onChange = (event: SyntheticEvent) => {
        const target = event.target;
        if (target instanceof HTMLInputElement) {
            input$.next(target.value);
        }
    };

    return input$
        .do(mess => console.warn('kliknięto ' + mess))
        .debounceTime(1000)
        .switchMap(text => storeApi.getListByText(text))
        .startWith([])
        .do(list => console.warn('otrzymano nową listę: ', list))
        .map(list => {
            return {
                list: list,
                onChange: onChange
            };
        });
};