page-bus:在同一域的页面和框架之间共享事件发射器

时间:2021-05-22 22:43:17
【文件属性】:
文件名称:page-bus:在同一域的页面和框架之间共享事件发射器
文件大小:4KB
文件格式:ZIP
更新时间:2021-05-22 22:43:17
JavaScript 页面总线 在同一域的页面和框架之间共享事件发射器 该模块可以脱机工作,并且不依赖于任何网络IO。 在后台,localStorage API和窗口'storage'事件用于同步跨页面事件。 以前,此模块使用共享工作程序,但是共享工作程序需要为URL.createObjectURL() api选择一个母版,这非常复杂。 例子 只需创建一条总线,该总线将返回事件发射器: var createBus = require ( 'page-bus' ) ; var bus = createBus ( ) ; bus . on ( 'hello' , function ( msg ) { console . log ( 'msg=' , msg ) ;\n} ) ;\nbus . emit ( 'hello' , Date . now ( ) ) ; 使用browserify进行编译,然后
【文件预览】:
page-bus-master
----example()
--------simple.js(155B)
--------index.html(199B)
--------bus.js(405B)
----index.js(1KB)
----readme.markdown(1KB)
----package.json(795B)
----LICENSE(1KB)

网友评论