vlcn-io / js

Components to build apps in JavaScript atop cr-sqlite
MIT License
54 stars 6 forks source link

Do not notify listeners of updates until after xCommit #48

Open tantaman opened 9 months ago

tantaman commented 9 months ago

We currently call reactivity listeners on xUpdate

We should hold off and not do this till xCommit given the transaction could be rolled back.

tantaman commented 9 months ago

This is generally not a problem right now since listeners enqueue a query after being notified. That query is not allowed to run until the next transaction but if the transaction was reverted there was no reason to issue the query in the first place.

Also -- batching xUpdates callbacks into a single callback at the end of a transaction would improve perf.

cr-sqlite uses xCommit internally so we can't register a second xCommit callback since SQLite only allows one to be registered at a time. We need to instead expose a xCommitMulti that allows many commit listeners.

tantaman commented 9 months ago

This is generally not a problem right now since listeners enqueue a query after being notified. That query is not allowed to run until the next transaction

hmm, this is be a bug in the cross tab scenario where a query issued due to a notification from xUpdate will not wait until transaction commit to read.