本文整理汇总了Python中rx.core.Observable.to_async方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.to_async方法的具体用法?Python Observable.to_async怎么用?Python Observable.to_async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.core.Observable
的用法示例。
在下文中一共展示了Observable.to_async方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import to_async [as 别名]
def start(cls, func, scheduler=None):
"""Invokes the specified function asynchronously on the specified
scheduler, surfacing the result through an observable sequence.
Example:
res = rx.Observable.start(lambda: pprint('hello'))
res = rx.Observable.start(lambda: pprint('hello'), rx.Scheduler.timeout)
Keyword arguments:
func -- {Function} Function to run asynchronously.
scheduler -- {Scheduler} [Optional] Scheduler to run the function on. If
not specified, defaults to Scheduler.timeout.
Returns {Observable} An observable sequence exposing the function's
result value, or an exception.
Remarks:
The function is called immediately, not during the subscription of the
resulting sequence. Multiple subscriptions to the resulting sequence can
observe the function's result.
"""
return Observable.to_async(func, scheduler)()
示例2: create
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import to_async [as 别名]
def create():
def func(x, y, z):
return x + y + z
return Observable.to_async(func, scheduler)(1, 2, 3)