remote query without await
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
I don't know if this is intended, but it feels unintuitive.
This does not fetch:
<script lang="ts">
import { getPosts } from './data.remote';
const query = getPosts();
</script>
This does:
<script lang="ts">
import { getPosts } from './data.remote';
const query = getPosts();
query.loading
</script>
It seems like you have to access loading, current or error to trigger the fetch of the RemoteQueryFunction.
I created a little repo to showcase how i try to preload stuff for a component.
I would assume, that calling getPosts() would already start fetching.
Reproduction
https://github.com/hendrik-huels/bug-or-feature
Logs
System Info
tested on "@sveltejs/kit": "^2.63.0" and "@sveltejs/kit": "3.0.0-next.11"
Severity
annoyance
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and compare the two snippets: calling getPosts() alone versus reading query.loading, current, or error. Trace the RemoteQueryFunction behavior involved in that difference and determine whether invocation should start the fetch or whether the current behavior is intended. Done means the behavior is corrected or clearly documented, with the reproduction demonstrating the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100