本文整理汇总了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
示例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)
示例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)
示例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
示例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()
示例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
示例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])
示例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()
示例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()
示例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)
示例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())
示例12: selector
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
def selector(_):
return Observable.empty()
示例13: factory
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import empty [as 别名]
def factory():
return Observable.empty(scheduler)