Description
The reducers that manage a FirebaseListObservable
's internal array call the unwrapMapFn
utility function when emitting (see here, here, here and here).
This is less that ideal, as it means that (when not preserving snapshots) the elements in the emitted arrays will always be different object instances between emissions. That does not play nice with Angular's OnPush
change detection - which takes advantage of unchanged object references - and always emitting different objects incurs a significant performance penalty.
Version info
Angular: 2.4.5
Firebase: 3.4.0 (for Plunker compatibility)
AngularFire: 2.0.0-beta.7
How to reproduce these conditions
There is a plunk here.
Steps to set up and reproduce
See plunk above. To see the difference in performance:
- run the plunk
- wait for the lists to start rolling (they should roll alternately, every second)
- open up the dev tools and record a profile
- wait for a few seconds, allowing each list to roll several times
- stop the profiling
- look at the flame graph, noting the performance difference between the preserved (fast) and unwrapped (slow) change detection and DOM updates
Expected behavior
The arrays emitted by lists that unwrap snapshots should use the same unwrapped object for array elements that have not changed.
Actual behavior
Each time arrays of unwrapped snapshots are emitted by lists, the array elements are always different object instances - even if the elements have not actually changed.