Javascript の PubSub に問題があります。$.subscribe が値を出力しない理由を理解しようとしています。$.publish と $.subscribe の間のスコープのためだと思います。
他のモジュールにイベントをサブスクライブしてもらいたいです。どうすればいいですか?私はjsfiddleに例を置きます:
window.MQ = (function (window, document, undefined) {
"use strict";
function MQ() {
testPubSub();
function testPubSub() {
$.publish("test");
}
}
return MQ
})(this, this.document);
var mq = new MQ();
$.subscribe("test", function () {
console.log("print value");
});
ありがとう
ピート