本文整理汇总了Python中rx.core.Observable.empty方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.empty方法的具体用法?Python Observable.empty怎么用?Python Observable.empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.core.Observable
的用法示例。
在下文中一共展示了Observable.empty方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_empty_observer_throw_exception
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.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()
示例2: test_select_throws
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.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()
示例3: test_select_with_index_throws
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.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()
示例4: test_For_each_index_empty
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import empty [as 别名]
def test_For_each_index_empty(self):
lstX = []
Observable.empty().to_blocking().for_each(lambda x, i: lstX.append(x))
assert(lstX == [])
示例5: test_for_each_empty
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import empty [as 别名]
def test_for_each_empty(self):
lst = []
Observable.empty().to_blocking().for_each(lambda x: lst.append(x))
assert(lst == [])
示例6: selector
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import empty [as 别名]
def selector(_):
return Observable.empty()
示例7: create
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import empty [as 别名]
def create():
return Observable.empty(scheduler).time_interval(scheduler)
示例8: on_completed
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import empty [as 别名]
def on_completed(self):
self.on_next(Observable.empty())
示例9: factory
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import empty [as 别名]
def factory():
return Observable.empty(scheduler)
示例10: test_as_observable_hides
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import empty [as 别名]
def test_as_observable_hides(self):
some_observable = Observable.empty()
assert(some_observable.as_observable() != some_observable)