I recently used the observer pattern to implement feeds for a project we just launched. (www.epicmix.com, the homepage will scroll in new data feed items as people ski on the mountain, this is in live time) I have a JS class FeedDispatcher that fetches new feed items from the server. Different pages across the site display the items in the feed, and to get their data they have to subscribe to the FeedDispatcher.
The alternative was every time I needed to display feed items, I would have to write a new XHR request. This would have resulted in lots of code duplication. The observer pattern really helped me in this case. -Brian Wigginton On Jan 4, 2011, at 5:06 AM, אריה גלזר wrote: > I have used the observer pattern to create > http://mootools.net/forge/p/historymanager . it's basically a domain observer > that lets you monitor and change various object's state. It's a great way for > creating non-obtrusive communication between objects > > On Mon, Jan 3, 2011 at 8:51 PM, Mark McDonnell <[email protected]> wrote: > I've been reading through Stoyan Stefanov's latest book "JavaScript Patterns" > and was interested to know who here has used the Observer design pattern and > could you provide some examples of how you had used it. > > Here is a link to the example provided in the book: > https://gist.github.com/763762 > > At the moment it seems like I have 'a solution looking for a problem'. I can > see that this pattern could be quite useful with a more advanced JavaScript > application (being the event driven nature of JavaScript) but I'm not sure > what scenario I would use or could use such a pattern? > > Any ideas or suggestions you may have would be greatly appreciated. > > I know this is a bit of an odd request, but really I'm just interested to > know what 'real world' examples there are using this pattern so I can get a > better idea (when the time comes) how I can use it. > > Thanks! > -- > Mark McDonnell > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > > > > -- > Arieh Glazer > אריה גלזר > 052-5348-561 > http://www.arieh.co.il > http://www.link-wd.co.il > > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
