isModified helper
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 881
- PR merge metrics
- No merged PRs in 30d
Description
🚀 Feature Proposal
It would be great to have isModified helper, much like isDraft or current functions.
Motivation
More efficient updates of derived data in draft. Immer currently do have all necessary information, in it's essence it is stripped down version of current.
Can this be solved in user-land code?
It can be solved in following ways:
- You can compare
currentwithoriginalin draft - but that's unnecessarily expensive for simple yes/no query - You can
finishDraft, compare with original, thencreateDraftagain if necessary
Example
produce(deeplyNestedObject, (draft) => {
performOpaqueDeeplyNestedUpdates(draft)
if(isModified(draft.item)){
draft.item.modifiedOn = new Date()
}
})
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing isDraft, current, original, finishDraft, and createDraft APIs and how draft modification state is tracked. Define the public isModified behavior for nested drafts, add coverage for the requested opaque-update example, and confirm the existing test suite passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100