On Sep 28, 2004, at 6:32 PM, Brian Schröäer wrote:
> Because I'm not a ruby guru, and I want to teach them "the real ruby
> way" I ask you to donate a bit of your time to look at the source and
> make improvement suggestions.
> [...]
> http://ruby.brian-schroeder.de/ants/
I don't have either the time or expertise to fully investigate what
you've done here, but I wanted to comment on how similar are your
Observable module:
http://ruby.brian-schroeder.de/ants/source/observable-rb.html
and my EventTarget module:
http://phrogz.net/RubyLibs/EventTarget.rb
I changed mine to use symbols rather than strings after I saw yours,
since it's more Ruby-ish. (I had already decided yesterday morning to
use blocks by default and force &foo for existing method passing.)
I like how yours allows for 'forwarding along' arbitrary parameters,
although I feel like I prefer more structure in my life. (Said
structure being a discrete Event object with specified methods which is
used to shuttle data between the signal and the receiver.) It feels
like it provides a bit more de-coupling between the sender and the
receiver.
Your names are cleaner; mine are sort of ugly and confusing for the
sake of consistency with the DOM 2 Events model.
Oh, and BTW, you have two typos in your Usage example:
> observed.register(:foo) do | obeserved, *args |
I'm guessing that shouldn't be "obeserved"...should it be 'observed'
(to match your usage in the string?) or something else (is there a name
collision with the parameter passed to the initialize method)?
> puts "Observered object #{observed} signalled foo with arguments
#{args.inspect}
I'm guessing 'Observered' should be 'Observer' or 'Observed'.
--
(-, /\ \/ / /\/