You can use the observer pattern to create custom events or anytime you need to broadcast something to a set of listeners. One example is if you have a group of modules that needs to get the same data, it can subscribe itself to the observer. When you fetch a new data, it can broadcast that data to all the modules that's subscribed to it.
On Mon, Jan 3, 2011 at 1: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] > -- 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]
