

@extensionmethod(Observable, alias='flat_map')
def select_many(self, selector, result_selector=None):
    "One of the Following:\n    Projects each element of an observable sequence to an observable\n    sequence and merges the resulting observable sequences into one\n    observable sequence.\n\n    1 - source.select_many(lambda x: Observable.range(0, x))\n\n    Or:\n    Projects each element of an observable sequence to an observable\n    sequence, invokes the result selector for the source element and each\n    of the corresponding inner sequence's elements, and merges the results\n    into one observable sequence.\n\n    1 - source.select_many(lambda x: Observable.range(0, x), lambda x, y: x + y)\n\n    Or:\n    Projects each element of the source observable sequence to the other\n    observable sequence and merges the resulting observable sequences into\n    one observable sequence.\n\n    1 - source.select_many(Observable.from_([1,2,3]))\n\n    Keyword arguments:\n    selector -- A transform function to apply to each element or an\n        observable sequence to project each element from the source\n        sequence onto.\n    result_selector -- [Optional] A transform function to apply to each\n        element of the intermediate sequence.\n\n    Returns an observable sequence whose elements are the result of\n    invoking the one-to-many transform function collectionSelector on each\n    element of the input sequence and then mapping each of those sequence\n    elements and their corresponding source element to a result element.\n    "
    if result_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.map((lambda y: result_selector(x, y, i)))
        return self.flat_map(projection)
    if callable(selector):
        selector = adapt_call(selector)
        ret = _flat_map(self, selector)
    else:
        ret = _flat_map(self, (lambda _, __: selector))
    return ret

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