This package has been deprecated

Author message:

This package is no longer maintained.

vue-unquery
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

🪺 vue-unquery

NPM version

Lightweight data management for Vue in suspense & non-suspense contexts.

Basically an identical fork of TurboVue, but also suited for non-suspense setups.

All the credits to Erik C. Forés for his amazing work.

Key Features

  • 🎠 Create a query resource:
    • Suspense contexts: useAsyncQuery
    • Non-suspense contexts: useQuery
  • ⛲️ Support for lazy fetching via immediate: false option in non-suspense environments

Usage

Suspense Context

const [post, { isRefetching, refetch, mutate, error }] = await useAsyncQuery<Post>(
  () => `https://jsonplaceholder.typicode.com/posts/${props.id}`,
)

Non-Suspense Context

const [post, { isRefetching, refetch, mutate, error }] = useQuery<Post>(
  () => `https://jsonplaceholder.typicode.com/posts/${props.id}`,
)

Prevent initial data fetching with immediate: false:

const [post, { isRefetching, refetch, mutate, error }] = useQuery<Post>(
  () => `https://jsonplaceholder.typicode.com/posts/${props.id}`,
  { immediate: false }
)

// Later, call:
refetch()

Configuration

Note

All options from Turbo Query apply.

import { configure } from 'vue-unquery'

configure({
  async fetcher(key, { signal }) {
    const response = await fetch(key, { signal })
    if (!response.ok)
      throw new Error('Fetch request failed')
    return await response.json()
  },
})

License

MIT License © 2022-2023 Johann Schopplich

MIT License © 2022 Erik C. Forés

Readme

Keywords

none

Package Sidebar

Install

npm i vue-unquery

Weekly Downloads

1

Version

0.4.0

License

MIT

Unpacked Size

35.7 kB

Total Files

5

Last publish

Collaborators

  • johannschopplich