rx/operators/observable/flatmap.py
def flat_map(source: ObservableBase,
             mapper: Mapper = None,
             result_mapper: Callable[[Any, Any], Any] = None,
             mapper_indexed: MapperIndexed = None,
             result_mapper_indexed: Callable[[Any, Any, int], Any] = None
            ) -> ObservableBase:
    """One of the Following:
    Projects each element of an observable sequence to an observable
    sequence and merges the resulting observable sequences into one
    observable sequence.

    1 - source.flat_map(lambda x: Observable.range(0, x))

    Or:
    Projects each element of an observable sequence to an observable
    sequence, invokes the result mapper for the source element and each
    of the corresponding inner sequence's elements, and merges the results
    into one observable sequence.

    1 - source.flat_map(lambda x: Observable.range(0, x), lambda x, y: x + y)

    Or:
    Projects each element of the source observable sequence to the other
    observable sequence and merges the resulting observable sequences into
    one observable sequence.

    1 - source.flat_map(Observable.of(1, 2, 3))

    Keyword arguments:
    mapper -- A transform function to apply to each element or an
        observable sequence to project each element from the source
        sequence onto.
    result_mapper -- [Optional] A transform function to apply to each
        element of the intermediate sequence.
    mapper_indexed -- [Optional] A transform function to apply to each
        element or an
        observable sequence to project each element from the source
        sequence onto.
    result_mapper_indexed -- [Optional] A transform function to apply to each
        element of the intermediate sequence.

    Returns an observable sequence whose elements are the result of
    invoking the one-to-many transform function collectionSelector on each
    element of the input sequence and then mapping each of those sequence
    elements and their corresponding source element to a result element.
    """

    if result_mapper or result_mapper_indexed:
        def projection(x: Any, idx: int) -> Any:
            mapper_result = mapper(x) if mapper else mapper_indexed(x, idx)
            if isinstance(mapper_result, collections.Iterable):
                result = Observable.from_(mapper_result)
            else:
                result = Observable.from_future(mapper_result) if is_future(mapper_result) else mapper_result

            if result_mapper:
                return result.map(lambda y: result_mapper(x, y))
            else:
                return result.map(mapper_indexed=lambda y, i: result_mapper_indexed(x, y, i))

        return source.flat_map(mapper_indexed=projection)

    if callable(mapper) or callable(mapper_indexed):
        ret = _flat_map(source, mapper, mapper_indexed)
    else:
        ret = _flat_map(source, lambda _: mapper)

    return ret
One of the Following:
    Projects each element of an observable sequence to an observable
    sequence and merges the resulting observable sequences into one
    observable sequence.

    1 - source.flat_map(lambda x: Observable.range(0, x))

    Or:
    Projects each element of an observable sequence to an observable
    sequence, invokes the result mapper for the source element and each
    of the corresponding inner sequence's elements, and merges the results
    into one observable sequence.

    1 - source.flat_map(lambda x: Observable.range(0, x), lambda x, y: x + y)

    Or:
    Projects each element of the source observable sequence to the other
    observable sequence and merges the resulting observable sequences into
    one observable sequence.

    1 - source.flat_map(Observable.of(1, 2, 3))

    Keyword arguments:
    mapper -- A transform function to apply to each element or an
        observable sequence to project each element from the source
        sequence onto.
    result_mapper -- [Optional] A transform function to apply to each
        element of the intermediate sequence.
    mapper_indexed -- [Optional] A transform function to apply to each
        element or an
        observable sequence to project each element from the source
        sequence onto.
    result_mapper_indexed -- [Optional] A transform function to apply to each
        element of the intermediate sequence.

    Returns an observable sequence whose elements are the result of
    invoking the one-to-many transform function collectionSelector on each
    element of the input sequence and then mapping each of those sequence
    elements and their corresponding source element to a result element.
    
One of the Following:
Projects each element of an observable sequence to an observable
sequence and merges the resulting observable sequences into one
observable sequence.



Projects each element of an observable sequence to an observable
sequence, invokes the result mapper for the source element and each
of the corresponding inner sequence's elements, and merges the results
into one observable sequence.



Projects each element of the source observable sequence to the other
observable sequence and merges the resulting observable sequences into
one observable sequence.



Keyword arguments:
mapper -- A transform function to apply to each element or an
observable sequence to project each element from the source
sequence onto.
result_mapper -- [Optional] A transform function to apply to each
element of the intermediate sequence.
mapper_indexed -- [Optional] A transform function to apply to each
element or an
observable sequence to project each element from the source
sequence onto.
result_mapper_indexed -- [Optional] A transform function to apply to each
element of the intermediate sequence.

Returns an observable sequence whose elements are the result of
invoking the one-to-many transform function collectionSelector on each
element of the input sequence and then mapping each of those sequence
elements and their corresponding source element to a result element.
One of the Following : Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence . Projects each element of an observable sequence to an observable sequence invokes the result mapper for the source element and each of the corresponding inner sequence ' s elements and merges the results into one observable sequence . Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence . Keyword arguments : mapper -- A transform function to apply to each element or an observable sequence to project each element from the source sequence onto . result_mapper -- [ Optional ] A transform function to apply to each element of the intermediate sequence . mapper_indexed -- [ Optional ] A transform function to apply to each element or an observable sequence to project each element from the source sequence onto . result_mapper_indexed -- [ Optional ] A transform function to apply to each element of the intermediate sequence . Returns an observable sequence whose elements are the result of invoking the one - to - many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element .
def flat_map(source: ObservableBase,
             mapper: Mapper = None,
             result_mapper: Callable[[Any, Any], Any] = None,
             mapper_indexed: MapperIndexed = None,
             result_mapper_indexed: Callable[[Any, Any, int], Any] = None
            ) -> ObservableBase:
    if result_mapper or result_mapper_indexed:
        def projection(x: Any, idx: int) -> Any:
            mapper_result = mapper(x) if mapper else mapper_indexed(x, idx)
            if isinstance(mapper_result, collections.Iterable):
                result = Observable.from_(mapper_result)
            else:
                result = Observable.from_future(mapper_result) if is_future(mapper_result) else mapper_result
            if result_mapper:
                return result.map(lambda y: result_mapper(x, y))
            else:
                return result.map(mapper_indexed=lambda y, i: result_mapper_indexed(x, y, i))
        return source.flat_map(mapper_indexed=projection)
    if callable(mapper) or callable(mapper_indexed):
        ret = _flat_map(source, mapper, mapper_indexed)
    else:
        ret = _flat_map(source, lambda _: mapper)
    return ret
def flat_map ( source : ObservableBase , mapper : Mapper = None , result_mapper : Callable [ [ Any , Any ] , Any ] = None , mapper_indexed : MapperIndexed = None , result_mapper_indexed : Callable [ [ Any , Any , int ] , Any ] = None ) -> ObservableBase : if result_mapper or result_mapper_indexed : def projection ( x : Any , idx : int ) -> Any : mapper_result = mapper ( x ) if mapper else mapper_indexed ( x , idx ) if isinstance ( mapper_result , collections . Iterable ) : result = Observable . from_ ( mapper_result ) else : result = Observable . from_future ( mapper_result ) if is_future ( mapper_result ) else mapper_result if result_mapper : return result . map ( lambda y : result_mapper ( x , y ) ) else : return result . map ( mapper_indexed = lambda y , i : result_mapper_indexed ( x , y , i ) ) return source . flat_map ( mapper_indexed = projection ) if callable ( mapper ) or callable ( mapper_indexed ) : ret = _flat_map ( source , mapper , mapper_indexed ) else : ret = _flat_map ( source , lambda _ : mapper ) return ret
One of the Following:
Projects each element of an observable sequence to an observable
sequence and merges the resulting observable sequences into one
observable sequence.
One of the Following : Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence .
"""One of the Following:
    Projects each element of an observable sequence to an observable
    sequence and merges the resulting observable sequences into one
    observable sequence.

    1 - source.flat_map(lambda x: Observable.range(0, x))

    Or:
    Projects each element of an observable sequence to an observable
    sequence, invokes the result mapper for the source element and each
    of the corresponding inner sequence's elements, and merges the results
    into one observable sequence.

    1 - source.flat_map(lambda x: Observable.range(0, x), lambda x, y: x + y)

    Or:
    Projects each element of the source observable sequence to the other
    observable sequence and merges the resulting observable sequences into
    one observable sequence.

    1 - source.flat_map(Observable.of(1, 2, 3))

    Keyword arguments:
    mapper -- A transform function to apply to each element or an
        observable sequence to project each element from the source
        sequence onto.
    result_mapper -- [Optional] A transform function to apply to each
        element of the intermediate sequence.
    mapper_indexed -- [Optional] A transform function to apply to each
        element or an
        observable sequence to project each element from the source
        sequence onto.
    result_mapper_indexed -- [Optional] A transform function to apply to each
        element of the intermediate sequence.

    Returns an observable sequence whose elements are the result of
    invoking the one-to-many transform function collectionSelector on each
    element of the input sequence and then mapping each of those sequence
    elements and their corresponding source element to a result element.
    """
source
ObservableBase
mapper
Mapper
result_mapper
Callable[[Any, Any], Any]
mapper_indexed
MapperIndexed
result_mapper_indexed
Callable[[Any, Any, int], Any]