@domphy/query
v0.18.2
Published
Domphy Query - async state management, a 1-1 port of @tanstack/query-core
Maintainers
Readme
@domphy/query
domphy.com · Docs · npm
Framework-agnostic async state management for Domphy apps: fetching, caching, background refetching, mutations, infinite queries, and SSR hydration.
Install
npm install @domphy/queryQuick Example (Domphy adapter)
The recommended way to use @domphy/query in Domphy apps is through the Domphy adapter at @domphy/query/domphy:
import { QueryClient } from "@domphy/query"
import { createQuery } from "@domphy/query/domphy"
const client = new QueryClient()
client.mount()
const usersQuery = createQuery(client, {
queryKey: ["users"],
queryFn: () => fetch("/api/users").then((r) => r.json()),
})
const App = {
ul: (l) => (usersQuery.data(l) ?? []).map((user) => ({
li: user.name,
_key: user.id,
})),
hidden: (l) => usersQuery.isPending(l),
}createQuery returns a handle with reactive accessors: data(l), isPending(l), isError(l), error(l), status(l), isFetching(l), etc. — each accepts a listener for fine-grained subscriptions.
What It Includes
createQuery(client, options)— reactive query handle (adapter at@domphy/query/domphy)createMutation(client, options)— reactive mutation handlecreateInfiniteQuery(client, options)— paginated / cursor-based query handlebindResult(initial, subscribe)— wire any observer to Domphy reactivityQueryClient/QueryCache— fetch, cache, deduplicate, invalidateQueryObserver/QueriesObserver— low-level observer APIMutationObserver/MutationCache— create/update/delete with retryInfiniteQueryObserver— paginated and cursor-based datafocusManager/onlineManager— refetch on window focus and reconnecthydration— serialize the cache on the server, hydrate on the client
Documentation
License
MIT — see LICENSE.
