makeLiveCancellable method
构建一个绑定到lifecycle
的Cancellable
*weakRef
是否是弱引用的 保持兼容性为 false 将在3.0版本改为 true
Implementation
Cancellable makeLiveCancellable({Cancellable? other, bool weakRef = false}) {
assert(currentLifecycleState > LifecycleState.destroyed,
'Must be used before destroyed.');
if (currentLifecycleState <= LifecycleState.destroyed) {
return Cancellable()..cancel();
}
return _map
.putIfAbsent(this, () => _LiveCancellableManagerObserver(this))
._makeCancellableForLive(other, weakRef);
}