IndexedDB와 상호 작용하는 데 사용되는 개체가 있습니다. 데이터베이스 열기가 완료되면 속성이 2로 변경 될 준비가되었습니다. this.ready == 2가 될 때까지 기다리는 read 메소드를 어떻게 알 수 있습니까?다른 속성이 준비 될 때까지 메서드를 일시 중지합니다.
var db = {
open: function() {//a callback sets this.ready to 2 when the database has been successfully opened},
ready: 0,
read: function() {
if(!this.ready == 2) {//pause until this.ready == 2}
...
}
}
100 밀리 초마다 this.ready를 확인하기 위해 setTimeout을 사용하여 함수를 작성해야합니까? 아니면 좀 더 우아한 해결책이 있습니까?
도움이 될 수 있습니다. http://stackoverflow.com/questions/5346694/how-to-implement-a-lock-in-javascript – Tija