Skip to content
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(svelte-5-adapter): require options to be passed as function #7804

Merged
merged 4 commits into from
Jul 27, 2024

Conversation

lachlancollins
Copy link
Member

@lachlancollins lachlancollins commented Jul 27, 2024

A very common error that keeps coming up for work on the svelte 5 adapter is state_referenced_locally:

State referenced in its own scope will never update. Did you mean to reference it inside a closure? svelte(state_referenced_locally)

With the svelte 4 adapter, you can pass options as either a raw object, or a store of the object. In the initial work on the svelte 5 adapter, you could pass options as either a raw object, or a function returning the object. This PR removes the first method.

This is identical to how @tanstack/solid-query works: https://tanstack.com/query/latest/docs/framework/solid/quick-start

Before

const post = createQuery({
  queryKey: ['post', postId], // Won't detect if postId changes
  queryFn: () => getPostById(postId),
})

After

const post = createQuery(() => ({
  queryKey: ['post', postId],
  queryFn: () => getPostById(postId),
}))

Copy link

nx-cloud bot commented Jul 27, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 6ac294c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx affected --targets=test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build --parallel=3
✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link

pkg-pr-new bot commented Jul 27, 2024

commit: 6ac294c

pnpm add https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@7804
pnpm add https://pkg.pr.new/@tanstack/angular-query-experimental@7804
pnpm add https://pkg.pr.new/@tanstack/eslint-plugin-query@7804
pnpm add https://pkg.pr.new/@tanstack/query-async-storage-persister@7804
pnpm add https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@7804
pnpm add https://pkg.pr.new/@tanstack/query-core@7804
pnpm add https://pkg.pr.new/@tanstack/query-devtools@7804
pnpm add https://pkg.pr.new/@tanstack/query-persist-client-core@7804
pnpm add https://pkg.pr.new/@tanstack/query-sync-storage-persister@7804
pnpm add https://pkg.pr.new/@tanstack/react-query@7804
pnpm add https://pkg.pr.new/@tanstack/react-query-devtools@7804
pnpm add https://pkg.pr.new/@tanstack/react-query-next-experimental@7804
pnpm add https://pkg.pr.new/@tanstack/react-query-persist-client@7804
pnpm add https://pkg.pr.new/@tanstack/solid-query@7804
pnpm add https://pkg.pr.new/@tanstack/solid-query-devtools@7804
pnpm add https://pkg.pr.new/@tanstack/solid-query-persist-client@7804
pnpm add https://pkg.pr.new/@tanstack/svelte-query@7804
pnpm add https://pkg.pr.new/@tanstack/svelte-query-devtools@7804
pnpm add https://pkg.pr.new/@tanstack/svelte-query-persist-client@7804
pnpm add https://pkg.pr.new/@tanstack/vue-query@7804
pnpm add https://pkg.pr.new/@tanstack/vue-query-devtools@7804

Open in Stackblitz

More templates

@lachlancollins lachlancollins merged commit 8f190fd into svelte-5-adapter Jul 27, 2024
5 of 6 checks passed
@lachlancollins lachlancollins deleted the require-function-options branch July 27, 2024 04:41
lachlancollins added a commit that referenced this pull request Jul 28, 2024
* fix(svelte-5-adapter): Require options to be passed as function

* More fixes

* More fixes

* Update examples
lachlancollins added a commit that referenced this pull request Jul 29, 2024
* fix(svelte-5-adapter): Require options to be passed as function

* More fixes

* More fixes

* Update examples
lachlancollins added a commit that referenced this pull request Jul 31, 2024
* fix(svelte-5-adapter): Require options to be passed as function

* More fixes

* More fixes

* Update examples
lachlancollins pushed a commit that referenced this pull request Aug 2, 2024
docs(svelte-5-adapter): force runes mode for all examples (#7800)

* docs(examples): force runes mode for all examples

* Fix simple example mounting

* Fix type
feat(svelte-5-adapter): require options to be passed as function (#7804)

* fix(svelte-5-adapter): Require options to be passed as function

* More fixes

* More fixes

* Update examples

fix(svelte-5-adapter): function for `createMutation` options (#7805)

* fix(svelte-5-adapter): require function for createMutation options

* Fix type errors
refactor(svelte-5-adapter): simplify createBaseQuery (#7808)

* refactor: simplify createBaseQuery

* Don't take snapshot of queryKey
chore(svelte-5-adapter): tidy-up functions (#7809)

* chore(svelte-5-adapter): tidy-up functions

* Fix types

* Update svelte

Fix import extensions

chore: ignore state_snapshot_uncloneable in tests
lachlancollins pushed a commit that referenced this pull request Aug 9, 2024
docs(svelte-5-adapter): force runes mode for all examples (#7800)

* docs(examples): force runes mode for all examples

* Fix simple example mounting

* Fix type
feat(svelte-5-adapter): require options to be passed as function (#7804)

* fix(svelte-5-adapter): Require options to be passed as function

* More fixes

* More fixes

* Update examples

fix(svelte-5-adapter): function for `createMutation` options (#7805)

* fix(svelte-5-adapter): require function for createMutation options

* Fix type errors
refactor(svelte-5-adapter): simplify createBaseQuery (#7808)

* refactor: simplify createBaseQuery

* Don't take snapshot of queryKey
chore(svelte-5-adapter): tidy-up functions (#7809)

* chore(svelte-5-adapter): tidy-up functions

* Fix types

* Update svelte

Fix import extensions

chore: ignore state_snapshot_uncloneable in tests
lachlancollins pushed a commit that referenced this pull request Aug 30, 2024
docs(svelte-5-adapter): force runes mode for all examples (#7800)

* docs(examples): force runes mode for all examples

* Fix simple example mounting

* Fix type
feat(svelte-5-adapter): require options to be passed as function (#7804)

* fix(svelte-5-adapter): Require options to be passed as function

* More fixes

* More fixes

* Update examples

fix(svelte-5-adapter): function for `createMutation` options (#7805)

* fix(svelte-5-adapter): require function for createMutation options

* Fix type errors
refactor(svelte-5-adapter): simplify createBaseQuery (#7808)

* refactor: simplify createBaseQuery

* Don't take snapshot of queryKey
chore(svelte-5-adapter): tidy-up functions (#7809)

* chore(svelte-5-adapter): tidy-up functions

* Fix types

* Update svelte

Fix import extensions

chore: ignore state_snapshot_uncloneable in tests


Fix merge
lachlancollins pushed a commit that referenced this pull request Aug 30, 2024
docs(svelte-5-adapter): force runes mode for all examples (#7800)

* docs(examples): force runes mode for all examples

* Fix simple example mounting

* Fix type
feat(svelte-5-adapter): require options to be passed as function (#7804)

* fix(svelte-5-adapter): Require options to be passed as function

* More fixes

* More fixes

* Update examples

fix(svelte-5-adapter): function for `createMutation` options (#7805)

* fix(svelte-5-adapter): require function for createMutation options

* Fix type errors
refactor(svelte-5-adapter): simplify createBaseQuery (#7808)

* refactor: simplify createBaseQuery

* Don't take snapshot of queryKey
chore(svelte-5-adapter): tidy-up functions (#7809)

* chore(svelte-5-adapter): tidy-up functions

* Fix types

* Update svelte

Fix import extensions

chore: ignore state_snapshot_uncloneable in tests


Fix merge
lachlancollins pushed a commit that referenced this pull request Sep 25, 2024
docs(svelte-5-adapter): force runes mode for all examples (#7800)

* docs(examples): force runes mode for all examples

* Fix simple example mounting

* Fix type
feat(svelte-5-adapter): require options to be passed as function (#7804)

* fix(svelte-5-adapter): Require options to be passed as function

* More fixes

* More fixes

* Update examples

fix(svelte-5-adapter): function for `createMutation` options (#7805)

* fix(svelte-5-adapter): require function for createMutation options

* Fix type errors
refactor(svelte-5-adapter): simplify createBaseQuery (#7808)

* refactor: simplify createBaseQuery

* Don't take snapshot of queryKey
chore(svelte-5-adapter): tidy-up functions (#7809)

* chore(svelte-5-adapter): tidy-up functions

* Fix types

* Update svelte

Fix import extensions

chore: ignore state_snapshot_uncloneable in tests


Fix merge
lachlancollins pushed a commit that referenced this pull request Nov 4, 2024
docs(svelte-5-adapter): force runes mode for all examples (#7800)

* docs(examples): force runes mode for all examples

* Fix simple example mounting

* Fix type
feat(svelte-5-adapter): require options to be passed as function (#7804)

* fix(svelte-5-adapter): Require options to be passed as function

* More fixes

* More fixes

* Update examples

fix(svelte-5-adapter): function for `createMutation` options (#7805)

* fix(svelte-5-adapter): require function for createMutation options

* Fix type errors
refactor(svelte-5-adapter): simplify createBaseQuery (#7808)

* refactor: simplify createBaseQuery

* Don't take snapshot of queryKey
chore(svelte-5-adapter): tidy-up functions (#7809)

* chore(svelte-5-adapter): tidy-up functions

* Fix types

* Update svelte

Fix import extensions

chore: ignore state_snapshot_uncloneable in tests


Fix merge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant