Most viewed recipes tagged "reactive"http://code.activestate.com/recipes/tags/reactive/views/2012-02-14T23:43:53-08:00ActiveState Code RecipesObserver pattern implemented with Descriptor class (Python)
2012-02-14T23:43:53-08:00Rodney Drenthhttp://code.activestate.com/recipes/users/4050661/http://code.activestate.com/recipes/578038-observer-pattern-implemented-with-descriptor-class/
<p style="color: grey">
Python
recipe 578038
by <a href="/recipes/users/4050661/">Rodney Drenth</a>
(<a href="/recipes/tags/descriptor/">descriptor</a>, <a href="/recipes/tags/observer/">observer</a>, <a href="/recipes/tags/publish/">publish</a>, <a href="/recipes/tags/reactive/">reactive</a>, <a href="/recipes/tags/subscribe/">subscribe</a>).
</p>
<p>The observer pattern is implemented using an observable descriptor.
One creates instances of observable in a class, which allows observers to
subscribe to changes in the observable. Assigning a value to the observable
causes the suscribers to be notified. An observable can subscribe to another observable, in which case changes to the second propagate to subscribers of the first.
The subscribe method returns a Subscription object. When this object is deleted or becomes unreferenced, the subscription is cancelled.</p>
<p>This version compatible with Python 3.0
Example uses unittest to help in understanding the functionality.</p>