Re: observer pattern

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[whoops didn't hit reply-all]

On Wed, May 18, 2011 at 5:18 AM, Ken Guest <ken@xxxxxxxx> wrote:
> Lo,
>
> so, I'm wondering - how many of you use the observer pattern in php;
> and if so, do you implement it 'standalone' or with the spl classes?
> Is there any particular advantage to doing it "your way"; whichever
> your way is?
>
> Ken
>
> --
> http://blogs.linux.ie/kenguest/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I use it quite a bit over the various projects I maintain.  It allows
subjects to trigger events that observers can process if they're
interested, or better yet, completely ignore.  This allows
standardized code bases to create nice hooks that allow extensibility
without needing to place one-off code inside the main project.

A quick example might be on saving a record in your code, it triggers
an event, then an observer in a custom site watches for said event and
injects/updates a search entry in Lucene.  This way one site can have
a custom search engine that another site might not need.

I started off with the concepts I found in
http://examples.stubbles.net/docroot/events/ but created my own
because I wanted something stand-alone.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux