Exemplo n.º 1
0
 def __init__(self, scheduler: Scheduler = None):
     self.subject = Subject()
     if scheduler is None:
         self.msgs = self.subject.pipe(as_observable())
     else:
         self.msgs = self.subject.pipe(subscribe_on(scheduler),
                                       as_observable())
Exemplo n.º 2
0
    def __init__(self, websocket, key, iv, device_id):
        self.websocket = websocket
        self.key = key
        self.iv = iv
        self.device_id = device_id

        self.state = ConnectionState.Initial
        self._messageSubject = rx.subject.Subject()
        self.mc = 0

        self.messages = self._messageSubject.pipe(ops.as_observable())
Exemplo n.º 3
0
    def wrapper(*args) -> Observable:
        subject = AsyncSubject()

        def action(scheduler, state):
            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())
Exemplo n.º 4
0
    def wrapper(*args) -> Observable:
        subject = AsyncSubject()

        def action(scheduler, state):
            try:
                result = func(*args)
            except Exception as ex:
                subject.on_error(ex)
                return

            subject.on_next(result)
            subject.on_completed()

        scheduler.schedule(action)
        return subject.pipe(ops.as_observable())
Exemplo n.º 5
0
    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 = rx.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]
Exemplo n.º 6
0
 def create():
     return xs.pipe(ops.as_observable())
Exemplo n.º 7
0
 def create():
     return rx.never().pipe(ops.as_observable())
Exemplo n.º 8
0
 def test_as_observable_hides(self):
     some_observable = rx.empty()
     assert some_observable.pipe(ops.as_observable()) != some_observable