Mchl Posted January 25, 2010 Share Posted January 25, 2010 I was toying with implementing SplObserver and SplSubject interfaces today. Got it right I guess, but I am wondering now: how could I use this pattern in an actual web application? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/189771-observer-pattern-usage-examples/ Share on other sites More sharing options...
gizmola Posted January 25, 2010 Share Posted January 25, 2010 Typically these patterns are used in GUI's to help with event handling. In a web environment, they really aren't that useful. Quote Link to comment https://forums.phpfreaks.com/topic/189771-observer-pattern-usage-examples/#findComment-1001479 Share on other sites More sharing options...
Mchl Posted January 25, 2010 Author Share Posted January 25, 2010 Indeed GUI came to my mind as first example. Also any other asynchronous processes like listening to incoming traffic on port etc... Thing is, you don't really do much of these in PHP... [added] Some interesting examples here http://devzone.zend.com/article/5 Quote Link to comment https://forums.phpfreaks.com/topic/189771-observer-pattern-usage-examples/#findComment-1001483 Share on other sites More sharing options...
roopurt18 Posted January 25, 2010 Share Posted January 25, 2010 I don't know what these are, but I'm guessing they're for subscribing and reacting to messages. Such a thing could be useful if you were writing a PHP service with child threads. Quote Link to comment https://forums.phpfreaks.com/topic/189771-observer-pattern-usage-examples/#findComment-1001509 Share on other sites More sharing options...
Mchl Posted January 25, 2010 Author Share Posted January 25, 2010 Turns out it can be pretty useful! http://devzone.zend.com/article/4284 http://www.devshed.com/c/a/PHP/An-Introduction-to-the-Observer-Pattern-in-PHP/1/ Quote Link to comment https://forums.phpfreaks.com/topic/189771-observer-pattern-usage-examples/#findComment-1001515 Share on other sites More sharing options...
oni-kun Posted January 29, 2010 Share Posted January 29, 2010 This brings me back to some C# code I required for a small project. This pattern is especially useful for handling STDIN/IO observing and status updates for the observing class. Quote Link to comment https://forums.phpfreaks.com/topic/189771-observer-pattern-usage-examples/#findComment-1003604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.