angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Incorrect event names in API doc for $firebaseArray.$watch

Open gjungb opened this issue 11 years ago • 2 comments

The API doc for $firebaseArray.$watch (https://github.com/firebase/angularfire/blob/master/src/FirebaseArray.js#L245) is incorrect.

Wrong: <code>{ type: 'added|updated|moved|removed', key: 'key_of_item_affected'}</code> Right: <code>{ event: 'child_added|child_updated|child_moved|child_removed', key: 'key_of_item_affected'}</code>

gjungb avatar Apr 12 '15 17:04 gjungb

If you find yourself depending on those event names (i.e. listening to server events), it's likely that you've misunderstood the purpose of the AngularFire services and there's probably a better way to accomplish your goals. I'm surprised to see, in fact, that we pass anything into the $watch callback. That should have been removed before the 1.0 release.

In general, using $extend to modify the $$added, $$updated, and $$removed would be more appropriate for manipulating data and intercepting server events. Anything that can't be done with these should probably use a custom service and tap directly into the Firebase SDK.

katowulf avatar Apr 13 '15 15:04 katowulf

BTW: the $watch method is also documented here: https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebasearray-watchcb-context

gjungb avatar Apr 13 '15 19:04 gjungb