Manage subscriptions for dynamic properties
This implements subscription to and unsubscription from properties that are created and deleted at runtime for quiddities.
This is done first by creating a get_quiddity_by_id
function which manages a cache of Pyquiddity
instances. This function should always be called instead of calling sw.get_quid
because the later causes a new Pyquiddity
instance to be created and callback subscriptions are registers for every Pyquiddity
and a switcher Quiddity
can be associated for multiple Pyquiddity
instances.
All the calls to sw.get_quid
are transformed to get_quiddity_by_id
to make sure we are not creating new Pyquiddity
instance. Note that this mitigates #212 (closed) because it makes it very unlikely that switcherio instanciates more Pyquiddity
s than necessary.
This adds reset_property_subscriptions
that removes all property subscriptions for a quiddity and immediately resubscribes to all available properties.
This function is called when an info tree value is grafted or pruned at an adress of the form property.<something>
which ensures that we have up to date callbacks no matter the order in which we receive the events from the backend. (Its a bit brute force but it works)
Some unused buggy "pyquid specific signal" code was also removed from pyquiddity.