fix: allow query().current and other data properties to work in non-reactive contexts#15699
Conversation
🦋 Changeset detectedLatest commit: e117e75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This is intentional. There's a pretty good explanation here: https://svelte.dev/docs/kit/remote-functions#query-Deduplication Basically, because query.set((current) => [new, ...current]);Since set is already a noop if there's nothing listening for it, it'd achieve what you want. (It's also weird that, as written in this PR, you can access |
|
@elliott-with-the-longest-name-on-github I'm not sure I understand fully – is it not possible to just get the cached value if it exists and return undefined if it doesn't? This patch is working as expected for me, so is there a hidden bug I'm not seeing? A callback form of .set would definitely also work, yes. |
|
Ok we've discussed this at length and I think this is the right way to go, but if we're doing it with |
|
I've added the other properties. I'll make a new PR for the callback form of |
|
@ottomated we can leave the new |
query().current to work in non-reactive contextsquery().current and other data properties to work in non-reactive contexts
b77f00d
into
sveltejs:main
As of #15533,
query().currentno longer works in non-reactive contexts. I believe this is unwanted behavior -- take the following scenario:This PR fixes it by simply restoring the old behavior of
.currentreturningundefinedif the query has not been called yet.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits