示例#1
0
        def create():
            def subscribe(o):
                o.on_next(1)
                o.on_next(2)
                return Disposable.empty()

            return Observable.create_with_disposable(subscribe)
示例#2
0
        def create():
            def subscribe(o):
                d = BooleanDisposable()
                o.on_next(1)
                o.on_next(2)

                def action1(scheduler, state):
                    if not d.is_disposed:
                        o.on_next(3)

                scheduler.schedule_relative(600, action1)

                def action2(scheduler, state):
                    if not d.is_disposed:
                        o.on_next(4)

                scheduler.schedule_relative(700, action2)

                def action3(scheduler, state):
                    if not d.is_disposed:
                        o.on_next(5)

                scheduler.schedule_relative(900, action3)

                def action4(scheduler, state):
                    if not d.is_disposed:
                        o.on_next(6)

                scheduler.schedule_relative(1100, action4)

                return d

            return Observable.create_with_disposable(subscribe)
示例#3
0
文件: test_create.py 项目: zmyer/RxPY
        def create():
            def subscribe(o):
                d = BooleanDisposable()
                o.on_next(1)
                o.on_next(2)

                def action1(scheduler, state):
                    if not d.is_disposed:
                        o.on_next(3)
                scheduler.schedule_relative(600, action1)

                def action2(scheduler, state):
                    if not d.is_disposed:
                        o.on_next(4)
                scheduler.schedule_relative(700, action2)

                def action3(scheduler, state):
                    if not d.is_disposed:
                        o.on_next(5)
                scheduler.schedule_relative(900, action3)

                def action4(scheduler, state):
                    if not d.is_disposed:
                        o.on_next(6)
                scheduler.schedule_relative(1100, action4)

                return d
            return Observable.create_with_disposable(subscribe)
示例#4
0
文件: test_create.py 项目: zmyer/RxPY
 def create():
     def subscribe(o):
         o.on_completed()
         o.on_next(100)
         o.on_error('ex')
         o.on_completed()
         return Disposable.empty()
     return Observable.create_with_disposable(subscribe)
示例#5
0
        def create():
            def subscribe(o):
                o.on_error(ex)
                o.on_next(100)
                o.on_error("foo")
                o.on_completed()
                return Disposable.empty()

            return Observable.create_with_disposable(subscribe)
示例#6
0
    def test_create_with_disposable_observer_throws(self):
        def subscribe1(o):
            o.on_next(1)
            return Disposable.empty()

        def on_next(x):
            _raise("ex")

        with self.assertRaises(RxException):
            Observable.create_with_disposable(subscribe1).subscribe(on_next)

        def subscribe2(o):
            o.on_error("exception")
            return Disposable.empty()

        with self.assertRaises(RxException):
            Observable.create_with_disposable(subscribe2).subscribe(on_error=lambda ex: _raise("ex"))

        def subscribe3(o):
            o.on_completed()
            return Disposable.empty()

        with self.assertRaises(RxException):
            Observable.create_with_disposable(subscribe3).subscribe(on_completed=_raise("ex"))
示例#7
0
文件: test_create.py 项目: zmyer/RxPY
    def test_create_with_disposable_observer_throws(self):
        def subscribe1(o):
            o.on_next(1)
            return Disposable.empty()

        def on_next(x):
            _raise('ex')

        with self.assertRaises(RxException):
            Observable.create_with_disposable(subscribe1).subscribe(on_next)

        def subscribe2(o):
            o.on_error('exception')
            return Disposable.empty()

        with self.assertRaises(RxException):
            Observable.create_with_disposable(subscribe2).subscribe(on_error=lambda ex: _raise('ex'))

        def subscribe3(o):
            o.on_completed()
            return Disposable.empty()

        with self.assertRaises(RxException):
            Observable.create_with_disposable(subscribe3).subscribe(on_completed=_raise('ex'))
示例#8
0
 def test_create_with_disposable_exception(self):
     with self.assertRaises(RxException):
         Observable.create_with_disposable(lambda: o, _raise("ex")).subscribe()
示例#9
0
文件: test_create.py 项目: zmyer/RxPY
 def test_create_with_disposable_exception(self):
     with self.assertRaises(RxException):
         Observable.create_with_disposable(lambda: o, _raise('ex')).subscribe()
示例#10
0
文件: test_create.py 项目: zmyer/RxPY
 def create():
     def subscribe(o):
         o.on_next(1)
         o.on_next(2)
         return Disposable.empty()
     return Observable.create_with_disposable(subscribe)