I think one of the best real world scenarios is a global selection manager. Lets say you have a tree view, list view and properties view. The list and property view should consume the selection of the tree. You could now hard wire the views by calling a function of the other two view or you could send just a event which can be observed/consumed by list and propeeties view. The advantage is that the views have not to know each other. They have just know the selection manager. On Jan 3, 2011 7:57 PM, "Jang Choe" <[email protected]> wrote: > 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]<jsmentors%[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]<jsmentors%[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]
