如何取消 FirebaseObjectObservable 订阅?
How do I cancel a FirebaseObjectObservable subscription?
我知道在其他情况下,我可以使用 unsubscribe() 关闭可观察对象,但据我所知,FirebaseObjectObservable 似乎没有该功能。我怎样才能关闭它?
this.rock = this.af.database.object('/rocks/'+ rockKey);
this.rock.subscribe(obj=>{
console.log("Can't stop the rock");
});
您没有取消订阅 Observable;您取消订阅。这与 Firebase observables 无关。
this.subscription = this.rock.subscribe(obj=>{
console.log("Can't stop the rock");
});
this.subscription.unsubscribe();
我知道在其他情况下,我可以使用 unsubscribe() 关闭可观察对象,但据我所知,FirebaseObjectObservable 似乎没有该功能。我怎样才能关闭它?
this.rock = this.af.database.object('/rocks/'+ rockKey);
this.rock.subscribe(obj=>{
console.log("Can't stop the rock");
});
您没有取消订阅 Observable;您取消订阅。这与 Firebase observables 无关。
this.subscription = this.rock.subscribe(obj=>{
console.log("Can't stop the rock");
});
this.subscription.unsubscribe();