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

refactor(svelte-query): rename FunctionedParams<T> to Accessor<T> for improved semantics and consistency, use in function return types #8534

Open
wants to merge 3 commits into
base: svelte-5-adapter
Choose a base branch
from

Conversation

braden-w
Copy link

@braden-w braden-w commented Jan 14, 2025

This change renames FunctionedParams<T> to Accessor<T> to improve code clarity and align with established patterns in the ecosystem. The change brings several key benefits:

  1. Alignment with Established Standards: The name Accessor<T> aligns with established patterns, particularly SolidJS's Accessor utility type.

For example, you can already see this same pattern is used in solid-query's createQuery.ts, createQueries.ts, isRestoring.ts

  1. Semantic Clarity: The term "Accessor" better describes the type's purpose - a function that provides access to a value. The previous name FunctionedParams was ambiguous and could be misinterpreted as parameters that have been "functioned" or transformed.

  2. Removal of Redundancy: The word "Params" in FunctionedParams<T> was redundant since this type is already used in parameter positions. For example:

export function createQuery<T>(
  options: Accessor<CreateQueryOptions<T>>,  // Clearer than FunctionedParams
  queryClient?: QueryClient
)
  1. Broader Type Utility: The Accessor type can be consistently reused to type function return types across the codebase, particularly in utility hooks like useIsFetching, useIsMutating, useIsRestoring, and context functions. This creates a unified type pattern for functions that provide access to reactive values.

zhihengGet and others added 3 commits December 14, 2024 18:11
docs(svelte-5-adapter): force runes mode for all examples (TanStack#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 (TanStack#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 (TanStack#7805)

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

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

* refactor: simplify createBaseQuery

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

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

* Fix types

* Update svelte

Fix import extensions

chore: ignore state_snapshot_uncloneable in tests


Fix merge
This change is more in line with solid.js's Accessor utility type and improves readability. The "Params" in FunctionedParams<T> is misleading since FunctionedParams<T> is already called invoked in the parameters of a function anyway
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.

2 participants