-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: Add emptyObject property for sending modified keys to server #243
Conversation
Thanks for opening this pull request!
|
Codecov Report
@@ Coverage Diff @@
## main #243 +/- ##
==========================================
+ Coverage 83.74% 83.78% +0.03%
==========================================
Files 78 78
Lines 7365 7370 +5
==========================================
+ Hits 6168 6175 +7
+ Misses 1197 1195 -2
Continue to review full report at Codecov.
|
@dblythy let me know what you think about the property name, |
New Pull Request Checklist
Issue Description
When fetching a saved object and then calling .save, all keys are marked as dirty and saved to the backend, causing unnecessary traffic and database ops.
Related issue: #242
Approach
Developers were able to accomplish this before this PR by creating a new instance of their
ParseObject
, setting theobjectId
andcreatedAt
to the object they want to modify, and then only modifying the needed keys. They could also do any of the following mentioned in #242 (comment).This PR makes the process easier with less work on the developer by adding a computed property called
emptyObject
to allParseObject
s that provides a copy of the respective ParseObject that only contains the currentobjectId
andcreatedAt
. If developers wants to only modify a subset of the keys, they can modify a mutable version of the empty object. When the mutations of the empty object are saved, only those keys are sent to the server as opposed to sending keys that were not modified before the save. Example's on how to use are in the playgrounds as well as below:A "possible breaking change" is introduced depending on how developers have created initializers for their
ParseObject
s. If a developer had aParseObject
with inits that looked like:it is recommended to leverage
extensions
to preserve the convenience initializer by converting to the following:If developers already implemented the empty initializer,
init()
or already useextensions
for inits, then no breaks to your code should occur. If the developer has required fields (non-optional fields) in their ParseObject's they have should already been specifying values or marking them as optional anyways as this prevents decoding the respective objects as parsePointer
's(see #157 (comment) for more info).TODOs before merging