[v2] Expose the previous value to change listeners
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.7k
- Forks
- 682
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 7
Description
onChange listeners may need to compare the current form value with the value immediately before the change. The listener context could support this by exposing an optional prevValue property:
prevValue?: TData
For a change event, prevValue would contain the value before that change was applied. It would not be present for other listener events.
Debounced listeners
The previous value should correspond to the specific change that ultimately invokes the listener. For example, if a debounced change listener receives five changes in quick succession, the callback would run after the timeout with the fourth value as prevValue and the fifth as the current value.
Some thoughts
setFieldValue and handleChange could capture the previous value and pass that snapshot through the listener context. The property needs to remain optional because the shared listener context is also used by events that are not change events.
Contributor guide
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 tracing setFieldValue and handleChange into the shared listener context and the debounced change-listener path. Add coverage showing prevValue is the value before the specific change, including debounced successive changes, and that it is absent for non-change events.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100