javascript - Clear all running intervals -
i trying clear intervals @ same time same id.
reason multiple agents can have calls originated them, works accordingly when more 1 agent/interval involved interval not cleared , best of understanding clearinterval ever clears last interval.
is possible clear intervals same time same id? or clear intervals?
i looked @ other questions regarding same topic didn't work me , wondered if there date method of handling this.
basic code idea:
var extenarray = []; //passport.js app.get('/index', checkloggedin, function (req, res) { res.render('index', { isauthenticated : req.isauthenticated(), user : req.user }); if(extenarray.length > 0){ intervalid = setinterval(bridgecall, 10000); console.log("running"); } }); function bridgecall() { if (extenarray.length > 0) { console.log("begin!") console.log("value removed array"); } else { error = ("no extensions left dial"); error(); if(extenarray.length < 1){ clearinterval(intervalid); console.log("cleared interval") } } }
every time extension called removed array want keep code sample possible, can flesh out if required.
is there way clear intervals same id @ same time?
thanks @jaromandax suggestion configured code , works based of suggestion keep of interval id's in array.
made modifications code sample given:
var extenarray = []; var interval = []; //passport.js app.get('/index', checkloggedin, function (req, res) { res.render('index', { isauthenticated : req.isauthenticated(), user : req.user }); if (extenarray.length > 0) { intervalid = setinterval(bridgecall, 10000); intervalarray.push(intervalid); console.log("running"); } }); function bridgecall() { if (extenarray.length > 0) { console.log("begin!") console.log("value removed array"); } else { error = ("no extensions left dial"); error(); if (extenarray.length < 1) { (i = 0; < intervalarray.length; i++) { clearinterval(intervalarray[i]); console.log("cleared interval") } } } }
Comments
Post a Comment