function MessageInfo() {
this.infoQueue = {};this.subscribe = function (eventTitle, fn) {
this.infoQueue[eventTitle] = fn; } this.publish = function () { var args = arguments[0]; var eventTitle = args[0]; if (!this.infoQueue[eventTitle]) { return; } var params = []; for (var i = 1; i < args.length; i++) { params.push(args[i]); } this.infoQueue[eventTitle].apply(this.infoQueue, params); }}var messageInfo;
(function ($) {
messageInfo || (messageInfo = new MessageInfo()); $.extend({ publish: function () { var args = []; for (var i = 0; i < arguments.length; i++) { args.push(arguments[i]); } messageInfo.publish(args); }, subscribe: function (eventTitle, fn) { messageInfo.subscribe(eventTitle, fn); } });})(jQuery);$(() => {
$.subscribe("12", function (id, name) {
console.log(id, name); });var id=10;
var name = "dome";
$.publish("12", id, name);
});