From: Kevin Smith Date: 2000-12-30T14:35:52+09:00 Subject: [ruby-talk:8338] Thoughts on the observer mix-in [long] (was:Re: Method as block to method) Nathaniel Talbott wrote: >Well, when I first implemented my observable/observer, I had forgotten about >the Observable mixin, so I started from square one, trying to figure out the >simplest and most useful implementation of observer for my needs. What I >came up with (and have used several times now) is something like this (note >that I have not run this example code): (snip) >I'm curious to hear everyone else's thoughts on the pros and cons of both >the original observer scheme and my new scheme. As long as you can live with each observer only watching one thing, and each observable only exposing a single attribute/event, then the standard library solution seems close to ideal. I think you could solve the watching-multiple- observables using an intermediate class. The observer could cerate as many of these objects as you want, and each one would call you back in a different way when its observable changed. I'm not sure about an observable sending notifications for multiple different events. That sounds like the object might be trying to do too much. Perhaps it should actually contain multiple observable objects, one for each group of observers. A set of wrapper methods in the container could delegate to the contained objects. Kevin