Skip to content

immediately update views on first write in batch and add flush#404

Open
juls0730 wants to merge 1 commit intoaspen-cloud:mainfrom
juls0730:main
Open

immediately update views on first write in batch and add flush#404
juls0730 wants to merge 1 commit intoaspen-cloud:mainfrom
juls0730:main

Conversation

@juls0730
Copy link
Copy Markdown

@juls0730 juls0730 commented Feb 1, 2026

This pull request updates subscribers' views on the first write in a batch, enabling the pattern of:

const data = // a triplit subscription view
triplit.insert('foo', { bar: 'baz' })
console.log(data) // data will now have { bar: 'baz' } in its elements, when it previously wouldnt

It also adds a new flush function that will manually update reactive views and optionally sync writes to the server if that is desired. This enables patterns like this:

for (let i = 0; i < 100; i++) {
  triplit.insert('foo', { bar: `baz ${i}` })
}
await triplit.flush() // required to flush every write, since only the first of a batch is written by default, so baz 1-99 would be missing
console.log(data) // has every newly inserted element (baz 0-99)

The performance should be on par with the previous implementation according to my testing since the first push (that enables the first pattern I discussed) only updates local reactive views. If you have any questions, please let me know.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 1, 2026

@juls0730 is attempting to deploy a commit to the Aspen Cloud Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant