2
브라우저 기반 클라이언트에서 디버그 진단을 구현하려고하는데 해당 구독자가없는 Bacon 버스에 푸시 된 이벤트를 감지해야합니다.다른 구독자가없는 이벤트 구독
아이디어가 있으십니까? 당신이로드 bacon.js 후이 뭔가를 추가 할 수 디버깅을위한
브라우저 기반 클라이언트에서 디버그 진단을 구현하려고하는데 해당 구독자가없는 Bacon 버스에 푸시 된 이벤트를 감지해야합니다.다른 구독자가없는 이벤트 구독
아이디어가 있으십니까? 당신이로드 bacon.js 후이 뭔가를 추가 할 수 디버깅을위한
: 다음
(function() {
var old, idCounter, fun;
old = Bacon.Bus;
idCounter = 0;
fun = function() {
var result, id, push;
result = old.apply(this, arguments);
if (result == null) {
result = this;
}
id = "" + (idCounter++);
push = result.push;
result.push = function(val) {
if (!this.hasSubscribers()){
console.log("unsubscribed push to bus " + id, val);
}
return push.apply(this, arguments);
};
return result;
};
fun.prototype = old.prototype;
Bacon.Bus = fun;
}());
없는 가입자 (들)과 버스에 대한 모든 push()
가 기록됩니다
var bus = new Bacon.Bus();
bus.push(42); // Output: unsubscribed push to bus 0 42
bus.log("foo"); // Add subscriber
bus.push(42); // Output: foo 42