자바 스크립트에서 글로벌 타이머 개체를 만든 다음 콜백을 즉시 추가 할 수 있습니다. 이 방법을 사용하면 스크립트에서 하나의 전역 타이머를 사용하여 배수를 사용하여 리소스를 낭비하지 않고 특정 간격으로 모든 작업을 실행할 수 있습니다.다중 콜백을 사용하는 자바 스크립트의 글로벌 타이머
var timer = new function() {
clearInterval(this.interval);
//[1] At this point I want the Callbacks to be run
var self = this;
setTimeout(function() {self.timer()}, 200);
}
function otherObject = new function() {
//When created I want to bind my object's function called cb to the global timer at [1]
}
otherObject.prototype.cb = function() {
//Stuff that should be done every time the timer is run
}
var someObject = new otherObject();
가 어떻게 간격으로 실행 할 수 바인딩 (다른 개체 내에서 기능을있는 대부분의) 숫자 기능을 만들 것 :
이 내가 일을 조각 같이 할 수 있도록하려면 어떻게 비행 중에 내 타이머?
좋은 기사 요지이다 이 아이디어를 사용하여 몇 가지 장단점을 부릅니다. http://googlecode.blogspot.com/2009/07/gmail-for-mobile-html5-series-using.html google의 사람들로부터. 자세한 내용은 "하나의 고주파 타이머로 모든 것을 제어합니다." –