To exit setInterval(), Pebble.js

321 Views Asked by At

I am new to Pebble, I am now experimenting on a small program using polling, here is part of the code.

main.on('click', 'up', function(e) {
main.body("Now searching...");
var refreshIntervalId = setInterval(function(){ 
ajax({ url: 'http://myipaddress/service', type: 'json' },
function(data, XHRequest){
main.subtitle(data.author);
main.body(data.quote); 
XHRequest.abort();
if(data !== null && data !== undefined && data.author !== '') clearInterval(refreshIntervalId);
},
function(error, XHRequest){
main.title('error');
main.body(error); 
XHRequest.abort();
});
}, 5000);
});

The problem is I want to exit setinterval but I can't use clearInterval, just because it is not defined in pebble.js. Are there any solution to avoid using clearInterval to exit? or I used it in the wrong way?

0

There are 0 best solutions below