

def _flat_map(source, selector):

    def projection(x, i):
        selector_result = selector(x, i)
        if isinstance(selector_result, collections.Iterable):
            result = Observable.from_(selector_result)
        else:
            result = Observable.from_future(selector_result)
        return result
    return source.map(projection).merge_observable()

dataset/ETHPy150Open ReactiveX/RxPY/rx/linq/observable/selectmany.py _flat_map/original