def repeatSelf(self, count=None): assert isinstance(self, Observable) if count == None: return Observable.concat(itertools.repeat(self)) else: return Observable.concat(itertools.repeat(self, count))
def repeatSelf(self, count = None): assert isinstance(self, Observable) if count == None: return Observable.concat(itertools.repeat(self)) else: return Observable.concat(itertools.repeat(self, count))
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)])
def while_do(cls, condition, source): """Repeats source as long as condition holds emulating a while loop. Keyword arguments: condition -- {Function} 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 an observable {Observable} sequence which is repeated as long as the condition holds.""" source = Observable.from_future(source) return Observable.concat(Enumerable.while_do(condition, source))
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))
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))
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)
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. """ scheduler = kw.get("scheduler") if not scheduler and isinstance(args[0], Scheduler): scheduler = args[0] args = args[1:] else: scheduler = immediate_scheduler sequence = [Observable.from_array(args, scheduler), self] return Observable.concat(sequence)
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. """ scheduler = kw.get("scheduler") if not scheduler and isinstance(args[0], Scheduler): scheduler = args[0] args = args[1:] else: scheduler = immediate_scheduler sequence = [Observable.from_(args, scheduler), self] return Observable.concat(sequence)