Permalink
Browse files

Merge pull request #1 from apeace/master

Fix starting and stopping
  • Loading branch information...
2 parents d42243b + 52b4617 commit a4398aeca33695e46af011ece79392a5c9c6cec3 @ecto committed Nov 15, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/main.js
View
@@ -11,15 +11,16 @@ var ekg = new events.EventEmitter(),
module.exports = ekg;
ekg.start = function(interval){
- ekg.update(function(){
- interval = interval || 100;
- var cycle = setInterval(ekg.run, interval);
- return ekg;
- });
+ if (!cycle) {
+ ekg.update(function(){
+ interval = interval || 100;
+ cycle = setInterval(ekg.run, interval);
+ });
+ }
}
ekg.stop = function(){
- clearInterval(cycle);
+ if (cycle) clearInterval(cycle);
}
ekg.update = function(cb){

0 comments on commit a4398ae

Please sign in to comment.