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


Python Disposable.empty方法代码示例

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


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

示例1: invokeRec

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
    def invokeRec(self, scheduler, state):
      time = 0

      if self.hasResult:
        self.observer.onNext(self.result)

      try:
        if self.first:
          self.first = False
        else:
          state = self.parent.iterate(state)

        self.hasResult = self.parent.condition(state)

        if self.hasResult:
          self.result = self.parent.resultSelector(state)
          time = self.parent.timeSelector(state)
      except Exception as e:
        self.observer.onError(e)
        self.dispose()
        return Disposable.empty()

      if not self.hasResult:
        self.observer.onCompleted()
        self.dispose()
        return Disposable.empty()

      return self.parent.scheduler.scheduleWithRelativeAndState(
        state,
        time,
        self.invokeRec
      )
开发者ID:aguil,项目名称:RxPython,代码行数:34,代码来源:generate.py

示例2: subscribeCore

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
  def subscribeCore(self, observer):
    old = None
    new = None

    while True:
      old = self.observer.value

      if old is DisposedObserver.instance:
        raise Exception("Object has been disposed")

      if old is DoneObserver.completed:
        observer.onCompleted()
        return Disposable.empty()

      if isinstance(old, DoneObserver):
        observer.onError(old.exception)
        return Disposable.empty()

      if old is NoopObserver.instance:
        new = observer
      else:
        if isinstance(old, ListObserver):
          new = old.add(observer)
        else:
          new = ListObserver((old, observer))

      current = self.observer.compareExchange(new, old)

      if old is current:
        break

    return self.Subscription(self, observer)
开发者ID:aguil,项目名称:RxPython,代码行数:34,代码来源:subject.py

示例3: subscribeCore

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
  def subscribeCore(self, observer):
    d = self._subscribe(observer)

    if d == None:
      return Disposable.empty()
    else:
      return d
开发者ID:aguil,项目名称:RxPython,代码行数:9,代码来源:observable.py

示例4: propagate

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
    def propagate(self, scheduler, currentId):
      with self.gate:
        if self.hasValue and self.resourceId == currentId:
          self.observer.onNext(self.value)
        self.hasValue = False

      return Disposable.empty()
开发者ID:aguil,项目名称:RxPython,代码行数:9,代码来源:throttle.py

示例5: connect

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
    def connect(self, observer):
      #
      # We connect the given observer to the subject first, before performing any kind
      # of initialization which will register an event handler. This is done to ensure
      # we don't have a time gap between adding the handler and connecting the user's
      # subject, e.g. when the ImmediateScheduler is used.
      #
      # [OK] Use of unsafe Subscribe: called on a known subject implementation.
      #
      connection = self.subject.subscribe(observer)

      self.count += 1
      if self.count == 1:
        try:
          self.initialize()
        except Exception as e:
          self.count -= 1
          connection.dispose()

          observer.onError(e)
          return Disposable.empty()

      def dispose():
        connection.dispose()

        with self.parent.gate:
          self.count -=1
          if self.count == 0:
            self.parent.scheduler.schedule(self.removeHandler.dispose)
            self.parent.session = None

      return Disposable.create(dispose)
开发者ID:aguil,项目名称:RxPython,代码行数:34,代码来源:fromEvent.py

示例6: scheduled

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
    def scheduled(_, message):
      # time = message[0]
      notification = message[1]

      notification.accept(observer)

      return Disposable.empty()
开发者ID:aguil,项目名称:RxPython,代码行数:9,代码来源:reactive.py

示例7: scheduledSubscribe

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
  def scheduledSubscribe(self, scheduler, autoDetachObserver):
    try:
      autoDetachObserver.disposable = self.subscribeCore(autoDetachObserver)
    except Exception as e:
      if not autoDetachObserver.fail(e):
        raise e

    return Disposable.empty()
开发者ID:aguil,项目名称:RxPython,代码行数:10,代码来源:observable.py

示例8: scheduled

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
  def scheduled():
    try:
      subject.onNext(action())
      subject.onCompleted()
    except Exception as e:
      subject.onError(e)

    return Disposable.empty()
开发者ID:wrmsr,项目名称:RxPython,代码行数:10,代码来源:creationOperators.py

示例9: wrapper

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
  def wrapper(observer):
    a = subscribe(observer)

    if isinstance(a, Disposable):
      return a
    elif callable(a):
      return Disposable.create(a)
    else:
      return Disposable.empty()
开发者ID:wrmsr,项目名称:RxPython,代码行数:11,代码来源:creationOperators.py

示例10: run

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
 def run(self):
   try:
     result = self.parent.eval()
   except Exception as e:
     self.observer.onError(e)
     self.dispose()
     return Disposable.empty()
   else:
     return result.subscribeSafe(self)
开发者ID:aguil,项目名称:RxPython,代码行数:11,代码来源:ifOp.py

示例11: schedulerCallback

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
  def schedulerCallback(self, scheduler, state):
    with self.lock:
      if self.isAdded:
        self.group.remove(self.cancel)
      else:
        self.isDone = True

    self.run(state)

    return Disposable.empty()
开发者ID:aguil,项目名称:RxPython,代码行数:12,代码来源:scheduler.py

示例12: timeout

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
    def timeout(self, scheduler, currentId):
      timerWins = False

      with self.gate:
        self.switched = self.currentId == currentId
        timerWins = self.switched

      if timerWins:
        self.subscription.disposable = self.parent.other.subscribeSafe(self.getForewarder())

      return Disposable.empty()
开发者ID:aguil,项目名称:RxPython,代码行数:13,代码来源:timeout.py

示例13: tick

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
    def tick(self, scheduler, state):
      with self.gate:
        if state.isSpan:
          s = self.queue.popleft()
          s.onCompleted()

        if state.isShift:
          self.createWindow()

      self.createTimer()

      return Disposable.empty()
开发者ID:aguil,项目名称:RxPython,代码行数:14,代码来源:window.py

示例14: run

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
    def run(self):
      source = None
      disposable = Disposable.empty()

      try:
        resource = self.parent.resourceFactory()
        if resource != None:
          disposable = resource

        source = self.parent.observableFactory(resource)
      except Exception as e:
        return CompositeDisposable(Observable.throw(e).subscribeSafe(self), disposable)

      return CompositeDisposable(source.subscribeSafe(self), disposable)
开发者ID:aguil,项目名称:RxPython,代码行数:16,代码来源:using.py

示例15: subscribeSafe

# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
  def subscribeSafe(self, observer):
    if isinstance(self, ObservableBase):
      return self.subscribeCore(observer)
    elif isinstance(self, Producer):
      return self.subscribeRaw(observer, False)

    d = Disposable.empty()

    try:
      d = self.subscribeCore(observer)
    except Exception as e:
      observer.onError(e)

    return d
开发者ID:aguil,项目名称:RxPython,代码行数:16,代码来源:observable.py


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