TransferableSubscription
This subscription is hyper dynamic, allowing you to change DynamicOwner on the fly.
It works by creating DynamicSubscription-s under the hood with your provided owner and activate() and deactivate() methods, but it has a special semantic: when transferring this subscription from one active DynamicOwner to another active DynamicOwner, neither activate() nor deactivate() are called because continuity of active ownership is maintained.
So in effect, this subscription only cares whether it's owned or not, so it does not expose the
owner to you: notice the activate
callback is not provided with an Owner.
An example of where this is useful is tracking mounting and unmounting of elements in Laminar. If an element is mounted, we want to call activate(), if unmounted, we want to call deactivate(), but if the element is MOVED from one mounted parent to another mounted parent, it just remains mounted, this transition is of no interest to us. If not for this subscription's special design, we would need to call deactivate() to "detach" the subscription from its old parent's owner and then immediately afterwards call activate() to "attach" the subscription to the new parent's owner, but that would deactivate and then immediately re-activate all subscriptions on the Laminar element being moved (and all of its descendants), which would be very wasteful. Well, you do need to know Laminar to understand this example.