-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Svelte 5: Runes not tracking async dependencies #11424
Comments
This is to be expected. Runes are designed to read dependencies sync only – and given the browser has no native way to track async context (yet), this isn't possible to do otherwise. |
Thanks, that's what I assumed, but couldn't find any documentation/issue related to it. I guess the compiler could traverse the inside of e.g. |
@valterkraemer What if you call a function from a random npm module? The compiler is limited in context. |
I was thinking just the variables used inside of the Then this would work let derivedId = $derived.by(() => {
return Promise.resolve().then(() => chatId);
}); But not this function myFunc() {
return Promise.resolve().then(() => chatId);
}
let derivedId = $derived.by(myFunc); |
@valterkraemer That would break far too many cases as we now use runtime reactivity rather than compile time reactivity. |
Sorry to bother you guys, but what is the idiomatic way to call |
Did you guys every figure out a way to get Dexie |
What I did as a workaround, as mentioned in the original message, was adding the "reactive dependencies" before let identity = $derived.by(() => {
chatMessage.creatorId; // reactive dependency
return liveQuery(() => localDB.identity.get(chatMessage.creatorId));
}); |
Closing since both the |
Describe the bug
A value is only considered a dependency of a rune if it is called in the same event loop tick.
Reproduction
This won't re-evaluate when
chatId
changes. REPLbut using
$:
it does work. REPLworkaround is to e.g. do
My real life example is that Dexie's liveQuery stopped reacting to changes
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: