-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Proposal for alternative snapshot unwrapping implementations #883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Here are some contrived examples to demonstrate the proposal's usage. A snapshot could be mapped to a single property by doing something like this (this is not a particularly compelling use case, but it serves as an example):
A list observable's items could be mapped to instances of a particular class by doing something like this:
A
The wholesale replacement of the
|
And add a provider for the default unwrapSnapshot implementation. Closes angular#883 and angular#848.
And add a provider for the default unwrapSnapshot implementation. Closes angular#883 and angular#848.
And add a provider for the default unwrapSnapshot implementation. Closes angular#883 and angular#848.
And add a provider for the default unwrapSnapshot implementation. Closes angular#883 and angular#848.
I like the spirit of this. Look forward to seeing your pr or something similar merged soon. |
With the merging of PR #787 (for issue #302), I have a problem. The
$key
added to unwrapped snapshots is now not included in serialized items. This is an issue for me as it breaks the logging implementation that I use and also results in items that I do not want to put into a Redux store (@ngrx/store
) as they are not serializable (well, not without losing the$key
).It's simple enough to use a
map
operator to change the items, but that introduces another problem: if amap
is used on each item, the performance is massively downgraded asOnPush
change detection will see each item in the emitted list as being a different instance - even if item has not actually changed. This essentially the same issue that was fixed in PR #792 and the plunk in issue #791 demonstrates the performance impact.This is also closely related to issue #848. That issue mentions the performance impact of having to apply a secondary
map
. That issue's author mentions the performance penalty, but it's not clear whether the author is talking about the computational cost or the DOM manipulation cost, but the latter is likely to be the bottleneck.To solve the above problems, the proposal is to:
database/interfaces.ts
database/utils.ts
unwrapMapFn
tounwrapSnapshot
unwrapSnapshot
intodatabase/unwrap_snapshot(.spec).ts
, etc.unwrapSnapshot
as an exportUnwrapSnapshotProvider
that provides the default/current implementation, etc.unwrapSnapshot
option toFirebaseListObservable
, etc.It will be a non-breaking change that will allow for the wholesale injection of an alternative unwrap implementation and for the case-by-case specification of per-list unwrap implementations.
The text was updated successfully, but these errors were encountered: