Exemplo n.º 1
0
    def test_oneshot_timer_timespan_observer_throws(self):
        scheduler1 = TestScheduler()
        xs = reactivex.timer(11)
        xs.subscribe(lambda x: _raise("ex"), scheduler=scheduler1)

        self.assertRaises(RxException, scheduler1.start)

        scheduler2 = TestScheduler()
        ys = reactivex.timer(1, period=None)
        ys.subscribe(on_completed=lambda: _raise("ex"), scheduler=scheduler2)

        self.assertRaises(RxException, scheduler2.start)
Exemplo n.º 2
0
        def create():
            def mapper(xy):
                x, y = xy
                return "{}{}".format(x.value, y.value)

            return xs.pipe(
                ops.join(
                    ys,
                    lambda x: reactivex.timer(x.interval),
                    lambda y: reactivex.timer(y.interval),
                ),
                ops.map(mapper),
            )
Exemplo n.º 3
0
    def test_oneshot_timer_date_observer_throws(self):
        scheduler = TestScheduler()
        date = scheduler.to_datetime(250.0)
        xs = reactivex.timer(date)
        xs.subscribe(lambda x: _raise("ex"), scheduler=scheduler)

        self.assertRaises(RxException, scheduler.start)
Exemplo n.º 4
0
        def create():
            def mapper(xy):
                x, y = xy
                return "{}{}".format(x.value, y.value)

            return xs.pipe(
                ops.join(
                    ys,
                    lambda x: reactivex.timer(x.interval),
                    lambda y: reactivex.timer(y.interval).pipe(
                        ops.flat_map(
                            reactivex.throw(ex)
                            if y.value == "tin" else reactivex.empty())),
                ),
                ops.map(mapper),
            )
Exemplo n.º 5
0
    def delay_subscription(source: Observable[_T]) -> Observable[_T]:
        """Time shifts the observable sequence by delaying the subscription.

        Exampeles.
            >>> res = source.delay_subscription(5)

        Args:
            source: Source subscription to delay.

        Returns:
            Time-shifted sequence.
        """

        def mapper(_: Any) -> Observable[_T]:
            return reactivex.empty()

        return source.pipe(
            ops.delay_with_mapper(reactivex.timer(duetime, scheduler=scheduler), mapper)
        )
Exemplo n.º 6
0
        def create():
            def right_duration_mapper(y):
                if len(y.value) >= 0:
                    raise Exception(ex)
                else:
                    return reactivex.empty()

            def mapper(xy):
                x, y = xy
                return "{}{}".format(x.value, y.value)

            return xs.pipe(
                ops.join(
                    ys,
                    lambda x: reactivex.timer(x.interval),
                    right_duration_mapper,
                ),
                ops.map(mapper),
            )
Exemplo n.º 7
0
 def closing():
     curr = window[0]
     window[0] += 1
     return reactivex.timer(curr * 100)
Exemplo n.º 8
0
 def closing(x):
     return reactivex.timer(x)
Exemplo n.º 9
0
def interval_(
        period: typing.RelativeTime,
        scheduler: Optional[abc.SchedulerBase] = None) -> Observable[int]:

    return timer(period, period, scheduler)
Exemplo n.º 10
0
 def create():
     return reactivex.timer(1000)
Exemplo n.º 11
0
 def create():
     return reactivex.timer(-1)
Exemplo n.º 12
0
 def create():
     return reactivex.timer(duetime=300)
Exemplo n.º 13
0
 def create():
     return reactivex.timer(duetime=300, period=400)