-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(zbugs): useWatchQuery #3307
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Array of all the changes would make sense but I think each change has to be processed as it is received if the callback is consuming relationships.
I don't follow. |
Now I don't follow :-)
At this point in time the child relationships are ignored. What should really happen is that I should use the applyChange logic (which needs some fixes) so that the relationships gets filled in. This is pretty incomplete and that is why I decided to put it in zbugs and not in zero-client. |
return changeView; | ||
} | ||
|
||
export type Change<TSchema extends TableSchema> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to define a new type to prevent tight coupling with the ivm Change type
export type Change<TSchema extends TableSchema> = | ||
| { | ||
type: 'add'; | ||
row: Row<TSchema>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These do not contain the relationships
} | ||
} | ||
|
||
function changeViewFactory< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I wonder if we can reasonably push this down a layer so that it can be used in non-React environments like Cloudflare-DO, NodeJS, vanilla JS.
Your perlow contact in the channel had an amazing idea: to propagate
mutation name and args to client and drive effects off that. There was a
long thread.
a (phone)
…On Sat, Dec 21, 2024 at 8:35 AM Greg Baker ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In apps/zbugs/src/hooks/use-watch-query.tsx
<#3307 (comment)>:
> +
+ flush() {
+ if (!this.#queryComplete) {
+ return;
+ }
+
+ for (const change of this.#pendingChanges) {
+ for (const cb of this.#subscribers) {
+ cb(toChange(change));
+ }
+ }
+ this.#pendingChanges = [];
+ }
+}
+
+function changeViewFactory<
Hmmm I wonder if we can reasonably push this down a layer so that it can
be used in non-React environments like Cloudflare-DO, NodeJS, vanilla JS.
—
Reply to this email directly, view it on GitHub
<#3307 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAATUBDE5IWMJNVWCGJCZA32GWYHRAVCNFSM6AAAAABTSGDWCSVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKMJYHAYDINBRHA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
This is WIP but I want some feedback.
This creates a new hook that takes a callback that gets called with the changes that come out at the end of the pipeline.
This is based on the ideas I had last week (or the week before that?) when I first worked on adding the emoji change callbacks.
Usage:
Things that are not obvious/clean.