def create(): return rx.generate_with_relative_time( 0, lambda x: True, lambda x: x + 1, lambda x: x + 1 )
def create(): return rx.generate_with_relative_time( 0, lambda x: _raise(ex), lambda x: x + 1, lambda x: x + 1 )
def timed_emit(iterable: Iterable, get_interval: Callable[[Any], float]): it0, it1 = tee(iter(iterable), 2) def _next_item(x): try: return next(it0) except StopIteration: return None def _stop(x): try: next(it1) return True except StopIteration: return False def _next_interval(_item): delay = get_interval(_item) return delay return rx.generate_with_relative_time(_next_item(None), _stop, _next_item, _next_interval)
return None return _func def make_time(speed=2): it = iter(data) def _func(x): print('next preview for interval: ', x) return next(it)['t'] / speed return _func f0 = make_stop() f1 = make_relative() f2 = make_time(1) test_scheduler = TestScheduler() print(datetime.now()) rx.generate_with_relative_time(f1(0), lambda x: f0(x), lambda x: f1(x), lambda x: f2(x))\ .subscribe( lambda x: print(f't={datetime.now()} {x}'), # scheduler=test_scheduler ) time.sleep(14) #test_scheduler.start()
def create(): return rx.generate_with_relative_time(0, lambda x: x <= 3, lambda x: x + 1, lambda x: x + 1)
def create(): return rx.generate_with_relative_time(0, lambda x: True, lambda x: x + 1, lambda x: _raise(ex))