JavaScript事件总线架构 [英] javascript event bus architecture
问题描述
在这个视频( 相应的幻灯片),尼古拉斯Zakas presents我在想什么是一个事件总线架构。我不知道的是,与总线交互的呼叫是否应是异步或不?结果
第二个问题:如果调用是异步的,他们应该如何实施结果
谢谢
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
推荐答案
我相信他们是异步确实如此。
I believe they are asynchronous indeed.
我的猜测是,他们似乎是实现了的方法是使用自定义DOM事件
。
My guess is that way they seem to be implemented is by using custom DOM events
.
这是在JavaScript,你可以检查jQuery的触发文档脱钩一个有用的技术,寻找自定义字符串来看看如何触发一个自定义事件。
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.
这篇关于JavaScript事件总线架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!