本文整理汇总了Python中rx.disposable.CompositeDisposable.remove方法的典型用法代码示例。如果您正苦于以下问题:Python CompositeDisposable.remove方法的具体用法?Python CompositeDisposable.remove怎么用?Python CompositeDisposable.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.disposable.CompositeDisposable
的用法示例。
在下文中一共展示了CompositeDisposable.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_groupdisposable_remove
# 需要导入模块: from rx.disposable import CompositeDisposable [as 别名]
# 或者: from rx.disposable.CompositeDisposable import remove [as 别名]
def test_groupdisposable_remove():
disp1 = [False]
disp2 = [False]
def action1():
disp1[0] = True
d1 = Disposable(action1)
def action2():
disp2[0] = True
d2 = Disposable(action2)
g = CompositeDisposable(d1, d2)
assert g.length == 2
assert g.contains(d1)
assert g.contains(d2)
assert g.remove(d1)
assert g.length == 1
assert not g.contains(d1)
assert g.contains(d2)
assert disp1[0]
assert g.remove(d2)
assert not g.contains(d1)
assert not g.contains(d2)
assert disp2[0]
disp3 = [False]
def action3():
disp3[0] = True
d3 = Disposable(action3)
assert not g.remove(d3)
assert not disp3[0]
示例2: RecursiveScheduledFunction
# 需要导入模块: from rx.disposable import CompositeDisposable [as 别名]
# 或者: from rx.disposable.CompositeDisposable import remove [as 别名]
class RecursiveScheduledFunction(object):
def __init__(self, action, scheduler, method = None):
self.action = action
self.group = CompositeDisposable()
self.lock = RLock()
if method == None:
self.schedule = scheduler.scheduleWithState
else:
self.schedule = getattr(scheduler, method)
def run(self, state):
self.action(state, self.actionCallback)
def actionCallback(self, newState, dueTime = None):
self.isDone = False
self.isAdded = False
if dueTime == None:
self.cancel = self.schedule(
newState,
self.schedulerCallback
)
else:
self.cancel = self.schedule(
newState,
dueTime,
self.schedulerCallback
)
with self.lock:
if not self.isDone:
self.group.add(self.cancel)
self.isAdded = True
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()