[cloud_firestore] DocumentSnapshot data should be immutable #5588
Replies: 3 comments
-
@collinjackson is this a regression (since users were able to do this in the past) or an enhancement (since we want to be more proactive against this in the future)? |
Beta Was this translation helpful? Give feedback.
-
I think developers were relying on an undocumented behavior... it's mostly an enhancement request to be more proactive against this, unless someone wants to convince me that this is really a good idea. I've updated the label. Let me know if you feel otherwise! |
Beta Was this translation helpful? Give feedback.
-
Nope, I wanted to change the label to |
Beta Was this translation helpful? Give feedback.
-
In the past it was possible to mutate the
data
member of aDocumentSnapshot
and it would persist. Developers were relying on this behavior (see discussion here).We could make the data returned by
DocumentSnapshot
immutable to give a clear error to developers letting them know that mutations aren't supported instead of silently failing. This would also reduce the risk of unpredictable behavior when different parts of the code are mutating the same data map.For bonus points we could lazily convert the maps and cache the result to avoid unnecessary computation.
Beta Was this translation helpful? Give feedback.
All reactions