コード例 #1
0
ファイル: dowhile.py プロジェクト: Austin-cp/cp-0.1.1
def do_while(self, condition):
    """Repeats source as long as condition holds emulating a do while loop.

    Keyword arguments:
    condition -- {Function} The condition which determines if the source
        will be repeated.

    Returns an observable {Observable} sequence which is repeated as long
    as the condition holds.
    """

    return Observable.concat([self, Observable.while_do(condition, self)])
コード例 #2
0
ファイル: forin.py プロジェクト: xyicheng/RxPY
def for_in(values, result_mapper) -> ObservableBase:
    """Concatenates the observable sequences obtained by running the
    specified result mapper for each element in source.

    Keyword arguments:
    values -- A list of values to turn into an observable
        sequence.
    result_mapper -- A function to apply to each item in the
        values list to turn it into an observable sequence.
    Returns an observable sequence from the concatenated
    observable sequences.
    """

    return Observable.concat(Iterable.for_each(values, result_mapper))
コード例 #3
0
ファイル: repeat.py プロジェクト: ESSL-CQQ/RxPY
def repeat(self, repeat_count=None):
    """Repeats the observable sequence a specified number of times. If the
    repeat count is not specified, the sequence repeats indefinitely.

    1 - repeated = source.repeat()
    2 - repeated = source.repeat(42)

    Keyword arguments:
    repeat_count -- Number of times to repeat the sequence. If not
        provided, repeats the sequence indefinitely.

    Returns the observable sequence producing the elements of the given
    sequence repeatedly."""

    return Observable.concat(Enumerable.repeat(self, repeat_count))
コード例 #4
0
ファイル: repeat.py プロジェクト: zmyer/RxPY
def repeat(self, repeat_count=None):
    """Repeats the observable sequence a specified number of times. If the
    repeat count is not specified, the sequence repeats indefinitely.

    1 - repeated = source.repeat()
    2 - repeated = source.repeat(42)

    Keyword arguments:
    repeat_count -- Number of times to repeat the sequence. If not
        provided, repeats the sequence indefinitely.

    Returns the observable sequence producing the elements of the given
    sequence repeatedly."""

    return Observable.concat(Enumerable.repeat(self, repeat_count))
コード例 #5
0
ファイル: whiledo.py プロジェクト: Austin-cp/cp-0.1.1
def while_do(cls, condition, source):
    """Repeats source as long as condition holds emulating a while loop.

    Keyword arguments:
    :param types.FunctionType condition: The condition which determines if the
        source will be repeated.
    :param Observable source: The observable sequence that will be run if the
        condition function returns true.

    :returns: An observable sequence which is repeated as long as the condition
        holds.
    :rtype: Observable
    """

    source = Observable.from_future(source)
    return Observable.concat(Enumerable.while_do(condition, source))
コード例 #6
0
ファイル: concat.py プロジェクト: JohnWowUs/RxPY
def concat(self, *args):
    """Concatenates all the observable sequences. This takes in either an
    array or variable arguments to concatenate.

    1 - concatenated = xs.concat(ys, zs)
    2 - concatenated = xs.concat([ys, zs])

    Returns an observable sequence that contains the elements of each given
    sequence, in sequential order.
    """
    if isinstance(args[0], list):
        items = args[0]
    else:
        items = list(args)

    items.insert(0, self)
    return Observable.concat(items)
コード例 #7
0
ファイル: concat.py プロジェクト: vuchau/RxPY
def concat(self, *args):
    """Concatenates all the observable sequences. This takes in either an
    array or variable arguments to concatenate.

    1 - concatenated = xs.concat(ys, zs)
    2 - concatenated = xs.concat([ys, zs])

    Returns an observable sequence that contains the elements of each given
    sequence, in sequential order.
    """
    if isinstance(args[0], list):
        items = args[0]
    else:
        items = list(args)

    items.insert(0, self)
    return Observable.concat(items)
コード例 #8
0
ファイル: whiledo.py プロジェクト: ninmesara/RxPY
def while_do(cls, condition, source):
    """Repeats source as long as condition holds emulating a while loop.

    Arguments:

      condition (types.FunctionType): The condition which determines if the
        source will be repeated.
      source (Observable): The observable sequence that will be run if the
        condition function returns True.

    Returns:
      (Observable): An observable sequence which is repeated as long as the
        condition holds.
    """

    source = Observable.from_future(source)
    return Observable.concat(Enumerable.while_do(condition, source))
コード例 #9
0
ファイル: startswith.py プロジェクト: Austin-cp/cp-0.1.1
def start_with(self, *args, **kw):
    """Prepends a sequence of values to an observable sequence with an
    optional scheduler and an argument list of values to prepend.

    1 - source.start_with(1, 2, 3)
    2 - source.start_with(Scheduler.timeout, 1, 2, 3)

    Returns the source sequence prepended with the specified values.
    """

    if isinstance(args[0], Scheduler):
        scheduler = args[0]
        args = args[1:]
    else:
        scheduler = kw.get("scheduler", immediate_scheduler)

    sequence = [Observable.from_(args, scheduler), self]
    return Observable.concat(sequence)