Angularfire: how to unsubscribe after snapshotChanges().subscribe?

Created on 5 Mar 2018  路  2Comments  路  Source: angular/angularfire

If I added subscribe on value change, how can can I unsubscribe it?
Thanks!

https://github.com/angular/angularfire2/blob/master/docs/rtdb/objects.md#retrieving-the-snapshot
`this.itemRef = db.object('item');

this.itemRef.snapshotChanges().subscribe(action => {

console.log(action.type);

console.log(action.key)

console.log(action.payload.val())

});`

Most helpful comment

//Subscribe
subscription = this.itemRef.snapshotChanges().subscribe();

//Unsubscribe
subscription.unsubscribe()

All 2 comments

//Subscribe
subscription = this.itemRef.snapshotChanges().subscribe();

//Unsubscribe
subscription.unsubscribe()

@houfu, thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DennisSmolek picture DennisSmolek  路  3Comments

avanderbergh picture avanderbergh  路  3Comments

StephenFluin picture StephenFluin  路  3Comments

cre8 picture cre8  路  3Comments

sharomet picture sharomet  路  3Comments