feat: Removes emptyObject requirement #249
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New Pull Request Checklist
Issue Description
#243 required all ParseObjects to have an
init()due to the addition ofemptyObject. This reverts that requirement and instead provides emptyObject as a recommendation to the developer.Developers should feel empowered to add properties like
emptyObjectwhich require new instances ofParseObject’s on their own depending on their respective use cases. In addition, developers can also add extensions and custom methods. It is not the intent for theSwift SDKto attempt to do everything on behalf of the developer as the SDK’s design is enable and empower by maximizing the Swift and Parse has to offer.Related issue: #247
Approach
Allow developer to add
emptyObjectcomputed property toParseObject‘s on their own.emptyObjectis useful if you only want to send modified or particular values to the server instead of the whole object:/*: It's recommended the developer adds the emptyObject computed property or similar. Gets an empty version of the respective object. This can be used when you only need to update a a subset of the fields of an object as oppose to updating every field of an object. - note: Using an empty object and updating a subset of the fields reduces the amount of data sent between client and server when using `save` and `saveAll` to update objects. */ var emptyObject: Self { var object = Self() // Or any init of your object you want. Note, ideally you want an empty init so you don’t send unnecessary keys. object.objectId = objectId object.createdAt = createdAt return object }Which then allows you to do:
See #243 for more details…
TODOs before merging