定制 webmodules/jqbus 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

webmodules/jqbus

最新稳定版本:0.0.9

Composer 安装命令:

composer require webmodules/jqbus

包简介

JavaSript based message queue

README 文档

README

#JQBUS

In my module1 in some file module1.js

var bus = jqbus.instance();

bus.on("when_something_happens", function(){
    console.log("I want to be notified, so that i can do something");
});

In my module2, maybe in some other file module.js

var bus = jqbus.instance();

bus.publish("when_something_happens");

Now as you can see module1 has never interacted with mmodule2 or vice-versa, they are not even being discussed, but both modules have knowledge of jqbus and they created their own instances and somehow are able to communicate !!Hurray!!

So we have triggered some function in module1 from inside module2 without even having reference of module1, similarly we can have as many listeneres as we want in as many modules as we can. Optionally we can also pass data along with, triggering the callback function.

bus.on("when_something_happens", function(e,target,data){
    //data sent by trigger function
    console.log("I want to be notified, so that i can do something");
});

bus.publish("when_something_happens", { name : "Hello" });

In addition to passing data to different module, JQBUS is able to send data to different tab also for same domain.

we can remove listeners when we wish, by simply using

bus.off();

统计信息

  • 总下载量: 39
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 8
  • Forks: 1
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固