当前位置: 首页>>代码示例>>Python>>正文


Python Observable.timer方法代码示例

本文整理汇总了Python中rx.core.Observable.timer方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.timer方法的具体用法?Python Observable.timer怎么用?Python Observable.timer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rx.core.Observable的用法示例。


在下文中一共展示了Observable.timer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delay_subscription

# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import timer [as 别名]
def delay_subscription(self, duetime, scheduler=None):
    """Time shifts the observable sequence by delaying the subscription.

    1 - res = source.delay_subscription(5000) # 5s
    2 - res = source.delay_subscription(5000, Scheduler.timeout) # 5 seconds

    duetime -- Absolute or relative time to perform the subscription at.
    scheduler [Optional] Scheduler to run the subscription delay timer on.
        If not specified, the timeout scheduler is used.

    Returns time-shifted sequence.
    """

    scheduler = scheduler or timeout_scheduler

    def selector(_):
        return Observable.empty()

    return self.delay_with_selector(Observable.timer(duetime, scheduler), selector)
开发者ID:JohnWowUs,项目名称:RxPY,代码行数:21,代码来源:delaysubscription.py

示例2: interval

# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import timer [as 别名]
def interval(cls, period, scheduler=None):
    """Returns an observable sequence that produces a value after each
    period.

    Example:
    1 - res = rx.Observable.interval(1000)
    2 - res = rx.Observable.interval(1000, rx.Scheduler.timeout)

    Keyword arguments:
    period -- Period for producing the values in the resulting sequence
        (specified as an integer denoting milliseconds).
    scheduler -- [Optional] Scheduler to run the timer on. If not specified,
        rx.Scheduler.timeout is used.

    Returns an observable sequence that produces a value after each period.
    """

    scheduler = scheduler or TimeoutScheduler()
    return Observable.timer(period, period, scheduler)
开发者ID:ESSL-CQQ,项目名称:RxPY,代码行数:21,代码来源:interval.py


注:本文中的rx.core.Observable.timer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。