2017-02-19 4 views
0

내 Angular 2 앱에서 변경 사항 표를 수신해야합니다. Firebase. Angular2, Firebase 및 TypeScript를 사용하고 있습니다. 리스너가 있지만 데이터베이스 테이블을 변경할 때 실행되지 않습니다.Firebase에서 변경 사항을 수신하기 위해 테이블을 청취해야합니다.

테이블이 업데이트/변경 될 때 항상 청취자를 누르기 위해이 필요합니다. 청취자를 글로벌 장소에 배치해야하는 것 같습니다. 현재 리스너가 서비스 파일에 있습니다.

this.adminNotifications = new Firebase(_environment.firebaseUrl + "/adminNotifications"); 

taskSchedulerListner =(): Promise<any> => { 
    this.adminNotifications.on('value', function(snapshot: any) { 
     console.log("admin notification hit!"); 
    }); 
} 

당신이 다른 코드를 볼 필요가 있다면 알려주세요 :

이 내 시도이다. 현재 adminNotifications 테이블이 변경 될 때 청취자를 친 싶습니다. 즉, 위의 예제에서 console.log 메서드를 사용하려고합니다.

콘솔 오류가 발생하지 않으며 adminNotifications 테이블이 변경되면 아무 일도 발생하지 않습니다.

답변

0

나는이 똑같은 문제를 경험했으며, 청중을 돌려 보낼 때 약속을 지킬 필요가 없다는 것을 깨닫게되었습니다. 이 코드를 다시 조정하십시오.

this.adminNotifications = new Firebase(_environment.firebaseUrl + "/adminNotifications"); 

taskSchedulerListner = this.adminNotifications.on('value', function(snapshot: any) { 
     console.log("admin notification hit!"); 
    }); 
관련 문제