本文整理汇总了Python中rx.observable.Observable.while_do方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.while_do方法的具体用法?Python Observable.while_do怎么用?Python Observable.while_do使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.observable.Observable
的用法示例。
在下文中一共展示了Observable.while_do方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import while_do [as 别名]
def create():
def predicate(x):
n[0] += 1
if n[0] < 3:
return True
else:
raise Exception(ex)
return Observable.while_do(predicate, xs)
示例2: do_while
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import while_do [as 别名]
def do_while(self, condition):
"""Repeats source as long as condition holds emulating a do while loop.
Keyword arguments:
condition -- {Function} The condition which determines if the source
will be repeated.
Returns an observable {Observable} sequence which is repeated as long
as the condition holds."""
return Observable.concat([self, Observable.while_do(condition, self)])