Subscriptions
You can define subscribers functions to be called whenever a cell value change.
const cellA = sheet.new(1);
// create subscriptions on any cell
const unsubscribe = cellA.subscribe((v) => {
console.log({ v });
});
// later call `unsubscribe` to cancel the subscription
unsubscribe();
When using cells in Svelte files, you can use the $cell
sugar to subscribe
to a cell value for display. Note that there is a initial undefined
value
when using that sugar as the reactive subscription are initially output by the
Svelte compiler as let $cell;
.
Unlike Svelte, subscriptions are called in transactional batches, i.e. cells
wait until all updates are propagated in the Sheet
to dispatch notifications
once to subscribers. This prevents stuttering.