当前位置: 首页>>代码示例>>Python>>正文


Python Observable.create_with_disposable方法代码示例

本文整理汇总了Python中rx.core.Observable.create_with_disposable方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.create_with_disposable方法的具体用法?Python Observable.create_with_disposable怎么用?Python Observable.create_with_disposable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rx.core.Observable的用法示例。


在下文中一共展示了Observable.create_with_disposable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import create_with_disposable [as 别名]
        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)
开发者ID:JohnWowUs,项目名称:RxPY,代码行数:35,代码来源:test_create.py

示例2: test_create_with_disposable_observer_throws

# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import create_with_disposable [as 别名]
    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"))
开发者ID:JohnWowUs,项目名称:RxPY,代码行数:26,代码来源:test_create.py

示例3: test_create_with_disposable_exception

# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import create_with_disposable [as 别名]
 def test_create_with_disposable_exception(self):
     with self.assertRaises(RxException):
         Observable.create_with_disposable(lambda: o, _raise("ex")).subscribe()
开发者ID:JohnWowUs,项目名称:RxPY,代码行数:5,代码来源:test_create.py


注:本文中的rx.core.Observable.create_with_disposable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。