本文整理汇总了Python中rx.core.Observable.interval方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.interval方法的具体用法?Python Observable.interval怎么用?Python Observable.interval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.core.Observable
的用法示例。
在下文中一共展示了Observable.interval方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sample
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import interval [as 别名]
def sample(self, interval=None, sampler=None, scheduler=None):
"""Samples the observable sequence at each interval.
1 - res = source.sample(sample_observable) # Sampler tick sequence
2 - res = source.sample(5000) # 5 seconds
2 - res = source.sample(5000, rx.scheduler.timeout) # 5 seconds
Keyword arguments:
source -- Source sequence to sample.
interval -- Interval at which to sample (specified as an integer
denoting milliseconds).
scheduler -- [Optional] Scheduler to run the sampling timer on. If not
specified, the timeout scheduler is used.
Returns sampled observable sequence.
"""
scheduler = scheduler or timeout_scheduler
if interval is not None:
return sample_observable(self, Observable.interval(interval, scheduler=scheduler))
return sample_observable(self, sampler)
示例2: projection
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import interval [as 别名]
def projection(x):
return Observable.interval(10, scheduler).map(lambda a, b: x).take(x)