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


Python Disposable.empty方法代码示例

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


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

示例1: test_groupdisposable_contains

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
def test_groupdisposable_contains():
    d1 = Disposable.empty()
    d2 = Disposable.empty()

    g = CompositeDisposable(d1, d2)
    
    assert g.length == 2
    assert g.contains(d1)
    assert g.contains(d2)
开发者ID:AlexMost,项目名称:RxPY,代码行数:11,代码来源:test_disposable.py

示例2: __init__

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
    def __init__(self, enable_queue=True):
        super(ControlledSubject, self).__init__(self._subscribe)

        self.subject = Subject()
        self.enable_queue = enable_queue
        self.queue = [] if enable_queue else None
        self.requested_count = 0
        self.requested_disposable = Disposable.empty()
        self.error = None
        self.has_failed = False
        self.has_completed = False
        self.controlled_disposable = Disposable.empty()
开发者ID:jesonjn,项目名称:RxPY,代码行数:14,代码来源:controlledsubject.py

示例3: __subscribe

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
    def __subscribe(self, observer):
        self.check_disposed()
        if not self.is_stopped:
            self.observers.append(observer)
            return InnerSubscription(self, observer)

        if self.exception:
            observer.on_error(self.exception)
            return Disposable.empty()

        observer.on_completed()

        return Disposable.empty()
开发者ID:mvschaik,项目名称:RxPY,代码行数:15,代码来源:subject.py

示例4: wrapped_action

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
 def wrapped_action(self, state):
     try:
         return action(parent._get_recursive_wrapper(self), state)
     except Exception as ex:
         if not parent._handler(ex):
             raise Exception(ex)
         return Disposable.empty()
开发者ID:mvschaik,项目名称:RxPY,代码行数:9,代码来源:catchscheduler.py

示例5: schedule_work

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
            def schedule_work(_, state3):
                action(state3, inner_action)
                if is_added:
                    group.remove(d)
                else:
                    is_done[0] = True

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

示例6: action2

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
                def action2(scheduler1, state3):
                    if is_added:
                        group.remove(d)
                    else:
                        is_done[0] = True

                    recursive_action(state3)
                    return Disposable.empty()
开发者ID:phaufe,项目名称:RxPY,代码行数:10,代码来源:scheduler.py

示例7: fix_subscriber

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
            def fix_subscriber(subscriber):
                """Fix subscriber to check for None or function returned to 
                decorate as Disposable"""
            
                if subscriber is None:
                    subscriber = Disposable.empty()
                elif type(subscriber) == types.FunctionType:
                    subscriber = Disposable(subscriber)

                return subscriber
开发者ID:mvschaik,项目名称:RxPY,代码行数:12,代码来源:anonymousobservable.py

示例8: action

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
                def action(scheduler, state=None):
                    nonlocal is_done

                    #print "action", scheduler1, state3
                    if is_added:
                        group.remove(d)
                    else:
                        is_done = True
                    
                    recursive_action(state)
                    return Disposable.empty()
开发者ID:Reactive-Extensions,项目名称:RxPy,代码行数:13,代码来源:scheduler.py

示例9: subscribe

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
 def subscribe(observer):
     disposable = Disposable.empty()
     try:
         resource = resource_factory()
         if resource:
             disposable = resource
         
         source = observable_factory(resource)
     except Exception as exception:
         d = Observable.throw_exception(exception).subscribe(observer)
         return CompositeDisposable(d, disposable)
     
     return CompositeDisposable(source.subscribe(observer), disposable)
开发者ID:mvschaik,项目名称:RxPY,代码行数:15,代码来源:using.py

示例10: subscribe

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
    def subscribe(self, observer):
        conn = self.source.publish()
        subscription = conn.subscribe(observer)
        connection = [Disposable.empty()]

        def on_next(b):
            if b:
                connection[0] = conn.connect()
            else:
                connection[0].dispose()
                connection[0] = Disposable.empty()

        pausable = self.subject.distinct_until_changed().subscribe(on_next)
        return CompositeDisposable(subscription, connection[0], pausable)
开发者ID:jesonjn,项目名称:RxPY,代码行数:16,代码来源:pausable.py

示例11: __subscribe

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
 def __subscribe(self, observer):
     self.check_disposed()
     if not self.is_stopped:
         self.observers.append(observer)
         observer.on_next(self.value)
         return InnerSubscription(self, observer)
     
     ex = self.exception
     if ex:
         observer.on_error(ex)
     else:
         observer.on_completed()
     
     return Disposable.empty()
开发者ID:Reactive-Extensions,项目名称:RxPy,代码行数:16,代码来源:behaviorsubject.py

示例12: _process_request

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
    def _process_request(self, number_of_items):
        if self.enable_queue:
            #console.log('queue length', self.queue.length)

            while len(self.queue) >= number_of_items and number_of_items > 0:
                # console.log('number of items', number_of_items)
                self.subject.on_next(self.queue.shift())
                number_of_items -= 1

            if len(self.queue):
                return { "number_of_items": number_of_items, "return_value": True }
            else:
                return { "number_of_items": number_of_items, "return_value": False }

        if self.has_failed:
            self.subject.on_error(self.error)
            self.controlled_disposable.dispose()
            self.controlled_disposable = Disposable.empty()
        elif self.has_completed:
            self.subject.on_completed()
            self.controlled_disposable.dispose()
            self.controlled_disposable = Disposable.empty()

        return { "number_of_items": number_of_items, "return_value": False }
开发者ID:jesonjn,项目名称:RxPY,代码行数:26,代码来源:controlledsubject.py

示例13: request

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
    def request(self, number):
        check_disposed(self)
        self.dispose_current_request()

        r = self._process_request(number)
        number = r["number_of_items"]
        if not r["return_value"]:
            self.requested_count = number

            def action():
                self.requested_count = 0
            self.requested_disposable = Disposable(action)

            return self.requested_disposable
        else:
            return Disposable.empty()
开发者ID:jesonjn,项目名称:RxPY,代码行数:18,代码来源:controlledsubject.py

示例14: _subscribe

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
    def _subscribe(self, observer):
        with self.lock:
            self.check_disposed()
            if not self.is_stopped:
                self.observers.append(observer)
                return InnerSubscription(self, observer)

            ex = self.exception
            hv = self.has_value
            v = self.value

        if ex:
            observer.on_error(ex)
        elif hv:
            observer.on_next(v)
            observer.on_completed()
        else:
            observer.on_completed()

        return Disposable.empty()
开发者ID:AlexMost,项目名称:RxPY,代码行数:22,代码来源:asyncsubject.py

示例15: inner_action

# 需要导入模块: from rx.disposables import Disposable [as 别名]
# 或者: from rx.disposables.Disposable import empty [as 别名]
 def inner_action(scheduler, y):
     yy[0] = y
     return Disposable.empty()
开发者ID:AlexMost,项目名称:RxPY,代码行数:5,代码来源:test_immediatescheduler.py


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