如何删除承诺的通知回调?假设以下jsfiddle
http://jsfiddle.net/anand_anand84/n6syLacs/2/
如果我想从promise1回调列表中删除stepC以便不打印console.log("HEADER Received =", data);
,应该怎么做。
var i = 0;
var deferred = Q.defer();
var simualteQuotes = function () {
deferred.notify(i++);
return "ret 1"
};
var getQuote = function(scrip){
//Contains a map containing promises and corresponding scrips;
//returns the promise of the scrip
return deferred.promise;
}
var stepA = function (data) {
console.log("Chart Received =", data);
};
var stepB = function (data) {
console.log("MarketWatch Received =", data);
};
var stepC = function (data) {
console.log("HEADER Received =", data);
};
// then() can be used multiple times. It's like, for each then(), a callback is registered.
// and when the promise is fulfilled, all the registered callbacks are called
var promise1 = deferred.promise;
var promiseA = promise1.progress(stepA);
var promiseB = promise1.progress(stepB);
var promiseC = promise1.progress(stepC);
setInterval(simualteQuotes, 6000);