本文整理汇总了Python中rx.observable.Observable.from_方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.from_方法的具体用法?Python Observable.from_怎么用?Python Observable.from_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.observable.Observable
的用法示例。
在下文中一共展示了Observable.from_方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: merge
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import from_ [as 别名]
def merge(cls, *args):
"""Merges all the observable sequences into a single observable
sequence. The scheduler is optional and if not specified, the
immediate scheduler is used.
1 - merged = rx.Observable.merge(xs, ys, zs)
2 - merged = rx.Observable.merge([xs, ys, zs])
3 - merged = rx.Observable.merge(scheduler, xs, ys, zs)
4 - merged = rx.Observable.merge(scheduler, [xs, ys, zs])
Returns the observable sequence that merges the elements of the
observable sequences.
"""
if not args[0]:
scheduler = immediate_scheduler
sources = args[1:]
elif isinstance(args[0], Scheduler):
scheduler = args[0]
sources = args[1:]
else:
scheduler = immediate_scheduler
sources = args[:]
if isinstance(sources[0], list):
sources = sources[0]
return Observable.from_(sources, scheduler).merge_all()
示例2: go
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import from_ [as 别名]
def go():
scheduler = AsyncIOScheduler()
xs = Observable.from_([x for x in range(10)], scheduler=scheduler)
gen = xs.to_async_generator()
# Wish we could write something like:
# ys = (x for x in yield from gen())
while True:
x = yield from gen()
if x is None:
break
print(x)
示例3: start_with
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import from_ [as 别名]
def start_with(self, *args, **kw):
"""Prepends a sequence of values to an observable sequence with an
optional scheduler and an argument list of values to prepend.
1 - source.start_with(1, 2, 3)
2 - source.start_with(Scheduler.timeout, 1, 2, 3)
Returns the source sequence prepended with the specified values.
"""
scheduler = kw.get("scheduler")
if not scheduler and isinstance(args[0], Scheduler):
scheduler = args[0]
args = args[1:]
else:
scheduler = immediate_scheduler
sequence = [Observable.from_(args, scheduler), self]
return Observable.concat(sequence)