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


Python Observable.empty方法代码示例

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


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

示例1: test_select_throws

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def test_select_throws(self):
     try:
         Observable.return_value(1) \
             .select(lambda x, y: x) \
             .subscribe(lambda x: _raise("ex"))
     except RxException:
         pass
 
     try:
         Observable.throw_exception('ex') \
             .select(lambda x, y: x) \
             .subscribe(on_error=lambda ex: _raise(ex))
     except RxException:
         pass
 
     try:
         Observable.empty() \
             .select(lambda x, y: x) \
             .subscribe(lambda x: x, lambda ex: ex, lambda: _raise('ex'))
     except RxException:
         pass
 
     def subscribe(observer):
         _raise('ex')
 
     try:
         Observable.create(subscribe) \
             .select(lambda x: x) \
             .subscribe()
     except RxException:
         pass
开发者ID:mvschaik,项目名称:RxPY,代码行数:33,代码来源:test_select.py

示例2: branch

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
def branch(condition, thenSource, schedulerOrElseSource=None):
  assert callable(condition)
  assert isinstance(thenSource, Observable)

  if schedulerOrElseSource == None:
    return If(condition, thenSource, Observable.empty())
  elif isinstance(schedulerOrElseSource, Scheduler):
    return If(condition, thenSource, Observable.empty(schedulerOrElseSource))
  else:
    assert isinstance(schedulerOrElseSource, Observable)

    return If(condition, thenSource, schedulerOrElseSource)
开发者ID:aguil,项目名称:RxPython,代码行数:14,代码来源:imperativeOperators.py

示例3: case

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
def case(selector, sources, schedulerOrDefaultSource=None):
  assert callable(selector)
  assert isinstance(sources, dict)

  if schedulerOrDefaultSource == None:
    return Case(selector, sources, Observable.empty())
  elif isinstance(schedulerOrDefaultSource, Scheduler):
    return Case(selector, sources, Observable.empty(schedulerOrDefaultSource))
  else:
    assert isinstance(schedulerOrDefaultSource, Observable)

    return Case(selector, sources, schedulerOrDefaultSource)
开发者ID:aguil,项目名称:RxPython,代码行数:14,代码来源:imperativeOperators.py

示例4: test_select_with_index_throws

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def test_select_with_index_throws(self):
     try:
         return Observable.return_value(1) \
             .select(lambda x, index: x) \
             .subscribe(lambda x: _raise('ex'))
     except RxException:
         pass
 
     try:
         return Observable.throw_exception('ex') \
             .select(lambda x, index: x) \
             .subscribe(lambda x: x, lambda ex: _raise(ex))
     except RxException:
         pass
 
     try:
         return Observable.empty() \
             .select(lambda x, index: x) \
             .subscribe(lambda x: x, lambda ex: _, lambda : _raise('ex'))
     except RxException:
         pass
 
     try:
         return Observable.create(lambda o: _raise('ex')) \
             .select(lambda x, index: x) \
             .subscribe()
     except RxException:
         pass
开发者ID:mvschaik,项目名称:RxPY,代码行数:30,代码来源:test_select.py

示例5: test_empty_observer_throw_exception

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def test_empty_observer_throw_exception(self):
     scheduler = TestScheduler()
     xs = Observable.empty(scheduler)
     xs.subscribe(lambda x: None, lambda ex: None, lambda: _raise('ex'))
     
     with self.assertRaises(RxException):
         scheduler.start()
开发者ID:AlexMost,项目名称:RxPY,代码行数:9,代码来源:test_empty.py

示例6: test_empty_observer_throw_exception

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def test_empty_observer_throw_exception(self):
     scheduler = TestScheduler()
     xs = Observable.empty(scheduler)
     xs.subscribe(lambda x: None, lambda ex: None, lambda: _raise('ex'))
     
     try:
         return scheduler.start()
     except RxException:
         pass
开发者ID:mvschaik,项目名称:RxPY,代码行数:11,代码来源:test_empty.py

示例7: test_finally_only_called_once_empty

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
    def test_finally_only_called_once_empty(self):
        invasserte_count = [0]

        def action():
            invasserte_count[0] += 1
            return invasserte_count
        some_observable = Observable.empty().finally_action(action)

        d = some_observable.subscribe()
        d.dispose()
        d.dispose()
        self.assertEqual(1, invasserte_count[0])
开发者ID:AlexMost,项目名称:RxPY,代码行数:14,代码来源:test_finally.py

示例8: test_select_throws

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def test_select_throws(self):
     with self.assertRaises(RxException):
         Observable.return_value(1) \
             .map(lambda x, y: x) \
             .subscribe(lambda x: _raise("ex"))
     
     with self.assertRaises(RxException):
         Observable.throw_exception('ex') \
             .map(lambda x, y: x) \
             .subscribe(on_error=lambda ex: _raise(ex))
     
     with self.assertRaises(RxException):
         Observable.empty() \
             .map(lambda x, y: x) \
             .subscribe(lambda x: x, lambda ex: ex, lambda: _raise('ex'))
     
     def subscribe(observer):
         _raise('ex')
 
     with self.assertRaises(RxException):
         Observable.create(subscribe) \
             .map(lambda x: x) \
             .subscribe()
开发者ID:AlexMost,项目名称:RxPY,代码行数:25,代码来源:test_select.py

示例9: test_select_with_index_throws

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def test_select_with_index_throws(self):
     with self.assertRaises(RxException):
         return Observable.return_value(1) \
             .map(lambda x, index: x) \
             .subscribe(lambda x: _raise('ex'))
     
     with self.assertRaises(RxException):
         return Observable.throw_exception('ex') \
             .map(lambda x, index: x) \
             .subscribe(lambda x: x, lambda ex: _raise(ex))
     
     with self.assertRaises(RxException):
         return Observable.empty() \
             .map(lambda x, index: x) \
             .subscribe(lambda x: x, lambda ex: _, lambda : _raise('ex'))
     
     with self.assertRaises(RxException):
         return Observable.create(lambda o: _raise('ex')) \
             .map(lambda x, index: x) \
             .subscribe()
开发者ID:AlexMost,项目名称:RxPY,代码行数:22,代码来源:test_select.py

示例10: test_as_observable_hides

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def test_as_observable_hides(self):
     some_observable = Observable.empty()
     assert(some_observable.as_observable() != some_observable)
开发者ID:AlexMost,项目名称:RxPY,代码行数:5,代码来源:test_asobservable.py

示例11: on_completed

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def on_completed(self):
     self.on_next(Observable.empty())
开发者ID:jesonjn,项目名称:RxPY,代码行数:4,代码来源:manyselect.py

示例12: selector

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def selector(_):
     return Observable.empty()
开发者ID:michaelandersen,项目名称:RxPY,代码行数:4,代码来源:delaysubscription.py

示例13: factory

# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
 def factory():
     return Observable.empty(scheduler)
开发者ID:mvschaik,项目名称:RxPY,代码行数:4,代码来源:test_empty.py


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