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:
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.
onChangelisteners may need to compare the current form value with the value immediately before the change. The listener context could support this by exposing an optionalprevValueproperty:prevValue?: TDataFor a change event,
prevValuewould 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
prevValueand the fifth as the current value.Some thoughts
setFieldValueandhandleChangecould 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.