Problem:
Building apps with confirmation dialogs for destructive operations (bulk delete, mass updates). Currently:
- Change happens → onChange fires
- Show confirmation dialog
- If rejected → manually rollback to previous state
This is fragile because:
- Other listeners already reacted to the change
- Computed values recalculated unnecessarily
- UI flickers (change → rollback)
- Race conditions if user makes another change during dialog
Use case:
// User selects 50 nodes and clicks "Delete"
// Want to: intercept → show "Delete 50 nodes?" → allow/reject
Proposed solution:
store$.nodes.onBeforeChange(async ({ changes, value, prev }) => {
if (changes.length > 5) {
const confirmed = await showConfirmDialog(Update ${changes.length} items?);
if (!confirmed) {
return false; // Reject - change doesn't happen
}
}
return true; // Allow
});
Problem:
Building apps with confirmation dialogs for destructive operations (bulk delete, mass updates). Currently:
This is fragile because:
Use case:
// User selects 50 nodes and clicks "Delete"
// Want to: intercept → show "Delete 50 nodes?" → allow/reject
Proposed solution:
store$.nodes.onBeforeChange(async ({ changes, value, prev }) => {
if (changes.length > 5) {
const confirmed = await showConfirmDialog(
Update ${changes.length} items?);if (!confirmed) {
return false; // Reject - change doesn't happen
}
}
return true; // Allow
});