javascript event bus architecture

孤者浪人 提交于 2019-12-24 02:33:41

问题


In this video at 20:50 (corresponding slide), Nicholas Zakas presents what I think is an Event Bus architecture. What I don't know is whether the calls that interact with the Bus should be asynchronous or not?
The second question: if the calls are asynchronous, how should they be implemented?
Thank you


回答1:


I believe they are asynchronous indeed.

My guess is that way they seem to be implemented is by using custom DOM events.

This is a useful technique for decoupling in javascript and you can check jQuery's trigger docs, look for the 'custom' string to see how to fire a custom event.



来源:https://stackoverflow.com/questions/6808905/javascript-event-bus-architecture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!