I'd like to make a little utility to log what's happening in can-connect. I'm working on this now in an effort to debug bitballs.
Posting relevant code:
var connect = require("can-connect");
var WeakReferenceMap = require("can-connect/helpers/weak-reference-map");
var WeakReferenceSet = require("can-connect/helpers/weak-reference-set");
var sortedSetJSON = require("can-connect/helpers/sorted-set-json");
var eventQueue = require("can-event-queue/map/map");
// shared across all connections
var pendingRequests = 0;
var noRequestsTimer = null;
var requests = {
increment: function(connection){
pendingRequests++;
clearTimeout(noRequestsTimer);
},
decrement: function(connection){
pendingRequests--;
if(pendingRequests === 0) {
// this calls to the connection so that `notifyThereAreNoPendingRequests` can be trapped
noRequestsTimer = setTimeout(connection.notifyThereAreNoPendingRequests,module.exports.requestCleanupDelay);
}
if(pendingRequests < 0) {
pendingRequests = 0;
}
},
count: function(){
return pendingRequests;
},
notifyThereAreNoPendingRequests: function(){
requests.dispatch("end");
}
};
eventQueue(requests);
var constructorStore = connect.behavior("constructor/store",function(baseConnection){
var behavior = {
// do this so this method can be logged
notifyThereAreNoPendingRequests: function(){
requests.notifyThereAreNoPendingRequests();
},
This is the log function. It nests stack calls. Traps repeat calls over time.
I'd like to make a little utility to log what's happening in can-connect. I'm working on this now in an effort to debug bitballs.
Posting relevant code:
This is the log function. It nests stack calls. Traps repeat calls over time.