2011/7/12 dtang85 <dtan...@gmail.com>: > Over the past year I've been focussing on JS and one thing that I > haven't seen too much about is how developers architect their JS for > small and large sites/applications. I've been primarily using the > Publish/Subscribe pattern based on my own custom implementation of the > pattern, but I'm starting to think that it may get harder to maintain > my site/application as I write more JS, as my code will consist of > several publications and several subscriptions. How do you architect > your JavaScript in a site/application, and how do you effectively > incorporate a library into your architecture?
You could namespace your pub/sub event similar to how jQuery does it. Like: pubsub.subscribe('myevent.mycomponent', callback) then you could publish an event to just that component, or with the namespace, like pubsub.publish('myevent', args) or pubsub.publish('myevent.mycomponent', args). Same goes for the unsubscribe. -- Poetro -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com