Skip to content

feat: trigger reactive queries for lists on executeBatch#299

Closed
mlecoq wants to merge 3 commits into
OP-Engineering:mainfrom
mlecoq:fix_executeBatchReactive
Closed

feat: trigger reactive queries for lists on executeBatch#299
mlecoq wants to merge 3 commits into
OP-Engineering:mainfrom
mlecoq:fix_executeBatchReactive

Conversation

@mlecoq
Copy link
Copy Markdown

@mlecoq mlecoq commented Jul 7, 2025

fixes #296

Comment thread cpp/utils.cpp
}


std::optional<std::string> extract_modified_table(const std::string &sql) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I'm sorry, but I will probably not merge this. This is brittle and maintaining when people complain it's not working for their very particular use-case is going to bring me too much work, which I don't feel like doing. Sorry :) but feel free to fork your own version, it's MIT

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I could live with a patch, but if you have a better idea to implement this, I would be happy to update my pr, maybe we could add an api to manually trigger update on js side ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No thoughts from the top of my head, sorry, it's been a while since I implemented reactive queries. But basically, how it's working on transactions is the only way that is generic enough and not crazy. I believe they flush the queued updates from JS already but also, I don't want to expose the internals functions again because people complain too much and don't read the internal C++ so they end up dumping work on my lap.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that you have to limit the api surface for maintenance purpose, I didn't see flushPendingReactiveQueries earlier, but without a way to update pending_reactive_queries, I can’t use it. Maybe we could find a mechanism on reactiveExecute itself, with a specific fireOn flag to react to external events

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending_reactive_queries should be updated on their on based on the update hook, they don't need manual updating as far as I remember, but again, I already forgot what's in here. You need to read the whole C++ code to understand how things are connected.

@ospfranco
Copy link
Copy Markdown
Contributor

Took a quick look at this. There is no need to modify the native code. Execute batch should already trigger hooks and all that was needed was to call flushPendingReactiveQueries from the JS code of executeBatch.

Closing this in favor of #318

@ospfranco ospfranco closed this Sep 7, 2025
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.

[Request]: executeBatch and reactiveQueries

2 participants