StoreBeforeChangeHandler
See source codeHandler function called before a record is updated in the store. The handler receives the current and new versions of the record and can return a modified version or the original to prevent the change.
type StoreBeforeChangeHandler<R extends UnknownRecord> = (
prev: R,
next: R,
source: 'remote' | 'user'
) => R
Example
const handler: StoreBeforeChangeHandler<ShapeRecord> = (prev, next, source) => {
// Prevent shapes from being moved outside the canvas bounds
if (next.x < 0 || next.y < 0) {
return prev // Block the change
}
return next
}
Parameters
Name | Description |
---|---|
| The current version of the record in the store |
| The proposed new version of the record |
| Whether the change originated from 'user' interaction or 'remote' synchronization |
Prev
StoreAfterDeleteHandlerNext
StoreBeforeCreateHandler