I was trying to upgrade my Angularfire 4 code to its latest version. There are some breaking changes as it no longer emits $key. The official documentation states to manage it by nesting map operators that I am struggling hard to understand -
constructor(afDb: AngularFireDatabase) {
afDb.list('items').snapshotChanges().map(actions => {
return actions.map(action => ({ key: action.key, ...action.payload.val() }));
}).subscribe(items => {
return items.map(item => item.key);
});
}
How is this nested map working? Why can't I perform the same operation in single map operator?
You have to map the list to a list containing this key value. I just played around a bit with it and this is my firebase 4 vs firebase 5 code
Old code :
New code :