def test_as_observable_isnoteager(self): scheduler = TestScheduler() subscribed = [False] def subscribe(obs, scheduler=None): subscribed[0] = True disp = scheduler.create_hot_observable( on_next(150, 1), on_next(220, 2), on_completed(250) ).subscribe(obs) def func(): return disp.dispose() return func xs = reactivex.create(subscribe) xs.pipe(ops.as_observable()) assert not subscribed[0] def create(): return xs.pipe(ops.as_observable()) scheduler.start(create) assert subscribed[0]
def wrapper(*args: Any) -> Observable[_T]: subject: AsyncSubject[_T] = AsyncSubject() def action(scheduler: abc.SchedulerBase, state: Any = None) -> None: try: result = func(*args) except Exception as ex: # pylint: disable=broad-except subject.on_error(ex) return subject.on_next(result) subject.on_completed() _scheduler.schedule(action) return subject.pipe(ops.as_observable())
def create(): return xs.pipe(ops.as_observable())
def create(): return reactivex.never().pipe(ops.as_observable())
def test_as_observable_hides(self): some_observable = reactivex.empty() assert some_observable.pipe(ops.as_observable()) != some_observable