【文件属性】:
文件名称:publish-subscribe:jQuery的发布订阅脚本
文件大小:1KB
文件格式:ZIP
更新时间:2021-05-20 23:22:25
JavaScript
发布-订阅
jQuery的发布订阅机制。
代言人
jQuery 1x,2x。
用法
// Event listener for the game over event.
$.subscribe("game.end", function (evt, d) {
$(".receiver").text("CONGRATULATIONS YOUR NEW HI-SCORE " + d).show();
});
...
// Game is over, publish the player's score
$.publish("game.end", game.Score);
您应该在发布事件之前先对其进行订阅,否则publish将不会收到该事件的通知,因此预期的行为将不会执行。
来源
tutsplus.com
【文件预览】:
publish-subscribe-master
----README.md(553B)
----pub-sub.js(279B)