TransformOnObservable mixes the order of changes in a given change set? #1000
Replies: 1 comment 3 replies
-
Yeah, I'm definitely gonna classify this as a straight-up defect. Bottom line, if you drop Doing a clear and then re-adding items with some of the same keys, like you have here might be a niche scenario, but I can entirely imagine a valid one. More generally, if the API allows you to do it, there would have to be a VERY compelling, and intuitive reason for me to say it shouldn't be supported. Looking at the operator, innards, I think it's an issue with ordering of separate subscriptions. The operator does a This might be a good opportunity to re-write and re-optimize the whole operator, as we've done for some others recently. I'm not sure if there's an easy fix that doesn't involve getting rid of the whole two-subscriptions concept, in favor of a single subscription. @RolandPheasant @dwcullop Any objection to a rewrite? Or is there a simpler option I'm not seeing? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Ciao guys
I've been observing a weird behavior with
TransformOnObservable
. Namely, it mixes up the order of changes in a given change set.This is a minimal test reproducing the issue:
In
lastChangeSet
I'd expect to find 3Remove
s followed by 3Add
s. Instead, there are 3Update
s followed by 3Remove
s; as if theAddOrUpdate
s were called before theClear
somehow.Clearly,
innerCache.Clear()
makes little sense in this case. However, I think there might be real-life scenarios where an operation like that is legit. For instance, supposesourceCache
is representing the people living in a particular city selected by the user. If the user changes the city of interest, we may want to clear the cache and add people from the new city. If the key doesn't take into account the city (therefore allowing people from different cities to have the same key), any new people whose key was already in the cache will be incorrectly removed.Currently, we're working around this by using
EditDiff
rather thanEdit
, which will emit an update for any item with the same key. But I'd be curious to know if this is a bug or whether I'm misusing Dynamic Data in any way.Thanks
Lorenzo
Beta Was this translation helpful? Give feedback.
All reactions