{"name":"swrv","version":"0.7.7","license":"Apache-2.0","_id":"swrv@0.7.7","maintainers":[{"name":"darrenjennings","email":"dmjenn02@gmail.com"}],"homepage":"https://github.com/Kong/swrv#readme","bugs":{"url":"https://github.com/Kong/swrv/issues"},"dist":{"shasum":"c486198007e1e9edf27e8e966c7872cac7dd1bbd","tarball":"http://registry-npm.ywwl.com/swrv/download/swrv-0.7.7.tgz","fileCount":39,"integrity":"sha512-hOmpkPG1oVp8cZdDxQ1OPLK6/0dyzInAuwl8hxbNM3QPdhG1gdAbog3xOaV2swBLmVV32ZsOe3JsOoidePpBzA==","signatures":[{"sig":"MEUCIQDTPoNlhJGm1DJMHh/BvpmcewJEVosJnh0J90pOL6swpAIgJbP5c7nCdKRGvaOFNvAlxM7kBV/ZPVUqcQ5PRaWeRaU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":81528,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfhFv/CRA9TVsSAnZWagAAe5cP/jqXt8gepROhnUkxw1rf\n6XD1c0nHEJjyd4HVb+44lgQUhua/v9SyWIVZnlhPomekl6ZdAkdjzNA8OrOy\nE1dsuYZmxsfzLtVCtM08X8GP1Ec5KdT3MKBw6L/rqn7/PZ2vfwqXDfkMogoG\n1APaZSAeYoIj3SAixjLAAwgkeLbCQXxkeAHXXJ6Fe77X1ehpT3Eetr+LzSxv\nAfoyLLbCanKsS+isEXbuMjjfOQoQNruUt8emLGsA47x6pouoHpGbe8MFkA7N\nmNSbGzxcP6s3RdEBGxIPM92HiXd0Ep7VsjEX2my/JLu1l/rPJYkOUn9aTC2O\nM0UT0EwicvvP58L23LN+muQzDuSibao3+LmuWvziwmifH1Zu56he0VzWLN30\nv5kg3+XDDDpsznbjMxmCSOE41MDcalk3sb7vxcuCKZTsFKwn91DwcRxSaxJn\nuXSPBGpdmAMfzaOvl15ULALGx0kAji6DcJ/+iOqkcoKkov8CHu6wTeo7V6AP\nVC6pMbrFTnjgv3JzBXnZhF05hspX0vYSk7Z3mVxV6llFd7sJeREYrvYhX3jf\nf30RO3eCjqsJjJogPXzSVa9BODgN2oyQSxDaoCE5ya3uCRlPX4hhQbn72Ifp\n8FrD2KDZbgqnjoX3123MbZm/eIJjRwp1p8oqViN3QbJXf5R9P87IVvOVAN2w\nPvTe\r\n=PSSK\r\n-----END PGP SIGNATURE-----\r\n","size":21022,"noattachment":false,"key":"/swrv/-/swrv-0.7.7.tgz"},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./esm/index.js","gitHead":"793857e20dc1780f680056bb3afaddd4ff8bc1da","scripts":{"ac":"all-contributors","lint":"vue-cli-service lint","test":"vue-cli-service test:unit","build":"yarn build:esm && yarn build:cjs","build:cjs":"tsc --target es5 --module CommonJs -p tsconfig.build.json","build:esm":"tsc --target ESNext --module ES6 --outDir esm -p tsconfig.build.json","test-compat":"./tests/test-compat-all.sh","types:check":"tsc --noEmit"},"_npmUser":{"name":"darrenjennings","email":"dmjenn02@gmail.com"},"repository":{"url":"git+https://github.com/Kong/swrv.git","type":"git"},"_npmVersion":"6.14.6","description":"<p align=\"center\">     <img src=\"logo.png\" width=\"100px\" /> </p> <h1 align=\"center\">swrv</h1>","directories":{},"_nodeVersion":"12.6.0","_hasShrinkwrap":false,"devDependencies":{"vue":"^2.6.11","eslint":"^5.16.0","webpack":"^4.41.6","typescript":"~3.9.5","@types/jest":"^24.0.19","file-loader":"^5.0.2","babel-loader":"^8.1.0","jest-date-mock":"^1.0.8","@vue/test-utils":"1.0.3","@vue/cli-service":"^4.4.4","eslint-plugin-vue":"^5.0.0","vue-server-renderer":"^2.6.11","@vue/composition-api":"~0.6.0","all-contributors-cli":"^6.13.0","babel-preset-vca-jsx":"^0.3.5","@vue/cli-plugin-babel":"^4.4.4","vue-template-compiler":"^2.6.10","@vue/cli-plugin-eslint":"^4.4.4","@vue/cli-plugin-unit-jest":"^4.4.4","@vue/cli-plugin-typescript":"^4.4.4","@vue/eslint-config-standard":"^4.0.0","@vue/eslint-config-typescript":"^4.0.0"},"peerDependencies":{"@vue/composition-api":"^0.5.0"},"_npmOperationalInternal":{"tmp":"tmp/swrv_0.7.7_1602509823219_0.4788116708010801","host":"s3://npm-registry-packages"},"readme":"<p align=\"center\">\n  <img src=\"logo.png\" width=\"100px\" />\n</p>\n<h1 align=\"center\">swrv</h1>\n\n[![](https://img.shields.io/npm/v/swrv.svg)](https://www.npmjs.com/package/swrv) [![npm](https://img.shields.io/npm/dm/swrv)](https://www.npmjs.com/package/swrv) ![build](https://github.com/Kong/swrv/workflows/build/badge.svg)\n\n`swrv` (pronounced \"swerve\") is a library using the [Vue Composition API](https://vuejs.org/guide/extras/composition-api-faq.html) for remote data fetching. It is largely a port of [swr](https://github.com/zeit/swr).\n\n- [Documentation](https://docs-swrv.netlify.app/)\n\nThe name “SWR” is derived from stale-while-revalidate, a cache invalidation strategy popularized by HTTP [RFC 5861](https://tools.ietf.org/html/rfc5861). SWR first returns the data from cache (stale), then sends the fetch request (revalidate), and finally comes with the up-to-date data again.\n\nFeatures:\n\n- Transport and protocol agnostic data fetching\n- Fast page navigation\n- Interval polling\n- ~~SSR support~~ (removed as of version `0.10.0` - [read more](https://github.com/Kong/swrv/pull/304))\n- Vue 3 Support\n- Revalidation on focus\n- Request deduplication\n- TypeScript ready\n- Minimal API\n- Stale-if-error\n- Customizable cache implementation\n- Error Retry\n\nWith `swrv`, components will get a stream of data updates constantly and automatically. Thus, the UI will be always fast and reactive.\n\n## Table of Contents<!-- omit in toc -->\n\n- [Installation](#installation)\n  - [Vue 3](#vue-3)\n  - [Vue 2](#vue-2)\n- [Getting Started](#getting-started)\n- [Api](#api)\n  - [Parameters](#parameters)\n  - [Return Values](#return-values)\n  - [Config options](#config-options)\n- [Prefetching](#prefetching)\n- [Dependent Fetching](#dependent-fetching)\n- [Stale-if-error](#stale-if-error)\n- [State Management](#state-management)\n  - [useSwrvState](#useswrvstate)\n  - [Vuex](#vuex)\n- [Cache](#cache)\n  - [localStorage](#localstorage)\n  - [Serve from cache only](#serve-from-cache-only)\n  - [Per-app cache isolation](#per-app-cache-isolation)\n    - [In test suites](#in-test-suites)\n  - [Writing to a provided cache](#writing-to-a-provided-cache)\n- [Error Handling](#error-handling)\n- [FAQ](#faq)\n  - [How is swrv different from the swr react library](#how-is-swrv-different-from-the-swr-react-library)\n  - [Why does swrv make so many requests](#why-does-swrv-make-so-many-requests)\n  - [How can I refetch swrv data to update it](#how-can-i-refetch-swrv-data-to-update-it)\n- [Contributors ✨](#contributors-)\n\n## Installation\n\n### Vue 3\n\n```shell\nyarn add swrv\n```\n\n`swrv` supports every Vue 3 minor release since `3.2` (`^3.2.0`). Testing and bug reports track the latest patch of each minor.\n\n### Vue 2\n\nVue 2 reached end of life on 31 December 2023 and is no longer supported. The last releases to support it stay installable:\n\n- Vue 2.7 — `swrv@0.10.0`, under the `v2-latest` tag\n- Vue 2.6 and below — `swrv@0.9.6`, under the `legacy` tag. It uses the external `@vue/composition-api` plugin, set up as described in [a previous version of the README](https://github.com/Kong/swrv/blob/b621aac02b7780a4143c5743682070223e793b10/README.md).\n\n## Getting Started\n\n```vue\n<template>\n  <div>\n    <div v-if=\"error\">failed to load</div>\n    <div v-if=\"!data\">loading...</div>\n    <div v-else>hello {{ data.name }}</div>\n  </div>\n</template>\n\n<script>\nimport useSWRV from 'swrv'\n\nexport default {\n  name: 'Profile',\n\n  setup() {\n    const { data, error } = useSWRV('/api/user', fetcher)\n\n    return {\n      data,\n      error,\n    }\n  },\n}\n</script>\n```\n\nIn this example, the Vue Hook `useSWRV` accepts a `key` and a `fetcher` function. `key` is a unique identifier of the request, normally the URL of the API. And the fetcher accepts key as its parameter and returns the data asynchronously.\n\n`useSWRV` also returns 2 values: `data` and `error`. When the request (fetcher) is not yet finished, data will be `undefined`. And when we get a response, it sets `data` and `error` based on the result of fetcher and rerenders the component. This is because `data` and `error` are Vue [Refs](https://vuejs.org/api/reactivity-core.html#ref), and their values will be set by the fetcher response.\n\nNote that fetcher can be any asynchronous function, so you can use your favorite data-fetching library to handle that part. When omitted, swrv falls back to the  browser [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).\n\n## Api\n\n```ts\nconst { data, error, isValidating, mutate } = useSWRV(key, fetcher, options)\n```\n\n`useSWRV` must be called from a component `setup()` function or an active `effectScope()`.\n\n### Parameters\n\n| Param     | Required | Description                                                                                                                                                                                                                                  |\n| --------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `key`     | yes      | a unique key string for the request (or a reactive reference / watcher function / null) (advanced usage)                                                                                                                                     |\n| `fetcher` |          | a Promise returning function to fetch your data. If `null`, swrv will fetch from cache only and not revalidate. If omitted (i.e. `undefined`) then the [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) api will be used. |\n| `options` |          | an object of configuration options                                                                                                                                                                                                           |\n\n### Return Values\n\n- `data`: data for the given key resolved by fetcher (or undefined if not\n  loaded)\n- `error`: error thrown by fetcher (or undefined)\n- `isValidating`: if there's a request or revalidation loading\n- `mutate`: function to trigger the validation manually\n\n### Config options\n\nSee [Config Defaults](https://github.com/Kong/swrv/blob/1587416e59dad12f9261e289b8cf63da81aa2dd4/src/use-swrv.ts#L43)\n\n- `refreshInterval = 0` - polling interval in milliseconds. 0 means this is\n  disabled.\n- `dedupingInterval = 2000` - dedupe requests with the same key in this time\n  span\n- `ttl = 0` - time to live of response data in cache. 0 mean it stays around\n  forever.\n- `shouldRetryOnError = true` - retry when fetcher has an error\n- `errorRetryInterval = 5000` - error retry interval\n- `errorRetryCount: 5` - max error retry count\n- `revalidateOnFocus = true` - auto revalidate when window gets focused\n- `revalidateDebounce = 0` - debounce in milliseconds for revalidation. Useful\n  for when a component is serving from the cache immediately, but then un-mounts\n  soon thereafter (e.g. a user clicking \"next\" in pagination quickly) to avoid\n  unnecessary fetches.\n- `cache` - caching instance to store response data in. See\n  [src/lib/cache](src/lib/cache.ts), and [Cache](#cache) below.\n\n## Prefetching\n\nPrefetching can be useful for when you anticipate user actions, like hovering over a link. SWRV exposes the `mutate` function so that results can be stored in the SWRV cache at a predetermined time.\n\n```ts\nimport { mutate } from 'swrv'\n\nfunction prefetch() {\n  mutate(\n    '/api/data',\n    fetch('/api/data').then((res) => res.json())\n  )\n  // the second parameter is a Promise\n  // SWRV will use the result when it resolves\n}\n```\n\n## Dependent Fetching\n\nswrv also allows you to fetch data that depends on other data. It ensures the maximum possible parallelism (avoiding waterfalls), as well as serial fetching when a piece of dynamic data is required for the next data fetch to happen.\n\n```vue\n<template>\n  <p v-if=\"!projects\">loading...</p>\n  <p v-else>You have {{ projects.length }} projects</p>\n</template>\n\n<script>\nimport { ref } from 'vue'\nimport useSWRV from 'swrv'\n\nexport default {\n  name: 'Profile',\n\n  setup() {\n    const { data: user } = useSWRV('/api/user', fetch)\n    const { data: projects } = useSWRV(() => user.value && '/api/projects?uid=' + user.value.id, fetch)\n    // if the return value of the cache key function is falsy, the fetcher\n    // will not trigger, but since `user` is inside the cache key function,\n    // it is being watched so when it is available, then the projects will\n    // be fetched.\n\n    return {\n      user,\n      projects\n    }\n  },\n}\n</script>\n```\n\n## Stale-if-error\n\nOne of the benefits of a stale content caching strategy is that the cache can be served when requests fail.`swrv` uses a [stale-if-error](https://tools.ietf.org/html/rfc5861#section-4) strategy and will maintain `data` in the cache even if a `useSWRV` fetch returns an `error`.\n\n```vue\n<template>\n  <div v-if=\"error\">failed to load</div>\n  <div v-if=\"data === undefined && !error\">loading...</div>\n  <p v-if=\"data\">\n    hello {{ data.name }} of {{ data.birthplace }}. This content will continue\n    to appear even if future requests to {{ endpoint }} fail!\n  </p>\n</template>\n\n<script>\nimport { ref } from 'vue'\nimport useSWRV from 'swrv'\n\nexport default {\n  name: 'Profile',\n\n  setup() {\n    const endpoint = ref('/api/user/Geralt')\n    const { data, error } = useSWRV(endpoint.value, fetch)\n\n    return {\n      endpoint,\n      data,\n      error,\n    }\n  },\n}\n</script>\n```\n\n## State Management\n\n### useSwrvState\n\nSometimes you might want to know the exact state where swrv is during stale-while-revalidate lifecyle. This is helpful when representing the UI as a function of state. Here is one way to detect state using a user-land composable `useSwrvState` function:\n\n```js\nimport { ref, watchEffect } from 'vue'\n\nconst STATES = {\n  VALIDATING: 'VALIDATING',\n  PENDING: 'PENDING',\n  SUCCESS: 'SUCCESS',\n  ERROR: 'ERROR',\n  STALE_IF_ERROR: 'STALE_IF_ERROR',\n}\n\nexport default function(data, error, isValidating) {\n  const state = ref('idle')\n  watchEffect(() => {\n    if (data.value && isValidating.value) {\n      state.value = STATES.VALIDATING\n      return\n    }\n    if (data.value && error.value) {\n      state.value = STATES.STALE_IF_ERROR\n      return\n    }\n    if (data.value === undefined && !error.value) {\n      state.value = STATES.PENDING\n      return\n    }\n    if (data.value && !error.value) {\n      state.value = STATES.SUCCESS\n      return\n    }\n    if (data.value === undefined && error) {\n      state.value = STATES.ERROR\n      return\n    }\n  })\n\n  return {\n    state,\n    STATES,\n  }\n}\n```\n\nAnd then in your template you can use it like so:\n\n```vue\n<template>\n  <div>\n    <div v-if=\"[STATES.ERROR, STATES.STALE_IF_ERROR].includes(state)\">\n      {{ error }}\n    </div>\n    <div v-if=\"[STATES.PENDING].includes(state)\">Loading...</div>\n    <div v-if=\"[STATES.VALIDATING].includes(state)\">\n      <!-- serve stale content without \"loading\" -->\n    </div>\n    <div\n      v-if=\"\n        [STATES.SUCCESS, STATES.VALIDATING, STATES.STALE_IF_ERROR].includes(\n          state\n        )\n      \"\n    >\n      {{ data }}\n    </div>\n  </div>\n</template>\n\n<script>\nimport { computed } from 'vue'\nimport useSwrvState from '@/composables/useSwrvState'\nimport useSWRV from 'swrv'\n\nexport default {\n  name: 'Repo',\n  setup(props, { root }) {\n    const page = computed(() => root.$route.params.id)\n    const { data, error, isValidating } = useSWRV(\n      () => `/api/${root.$route.params.id}`,\n      fetcher\n    )\n    const { state, STATES } = useSwrvState(data, error, isValidating)\n\n    return {\n      state,\n      STATES,\n      data,\n      error,\n      page,\n      isValidating,\n    }\n  },\n}\n</script>\n```\n\n### Vuex\n\nMost of the features of swrv handle the complex logic / ceremony that you'd have to implement yourself inside a vuex store. All swrv instances use the same global cache, so if you are using swrv alongside vuex, you can use global watchers on resolved swrv returned refs. It is encouraged to wrap useSWRV in a custom composable function so that you can do application level side effects if desired (e.g. dispatch a vuex action when data changes to log events or perform some logic).\n\nVue 3 example:\n\n```vue\n<script>\nimport { defineComponent, ref, computed, watch } from 'vue'\nimport { useStore } from 'vuex'\nimport useSWRV from 'swrv'\nimport { getAllTasks } from './api'\n\nexport default defineComponent({\n  setup() {\n    const store = useStore()\n\n    const tasks = computed({\n      get: () => store.getters.allTasks,\n      set: (tasks) => {\n        store.dispatch('setTaskList', tasks)\n      },\n    })\n\n    const addTasks = (newTasks) => store.dispatch('addTasks', { tasks: newTasks })\n\n    const { data } = useSWRV('tasks', getAllTasks)\n\n    // Using a watcher, you can update the store with any changes coming from swrv\n    watch(data, newTasks => {\n      store.dispatch('addTasks', { source: 'Todoist', tasks: newTasks })\n    })\n\n    return {\n      tasks\n    }\n  },\n})\n</script>\n```\n\n## Cache\n\nBy default, a custom cache implementation is used to store fetcher response data cache, in-flight promise cache, and ref cache. Response data cache can be customized via the `config.cache` property. Built in cache adapters:\n\n### localStorage\n\nA common usage case to have a better _offline_ experience is to read from `localStorage`. Checkout the [PWA example](https://github.com/Kong/swrv/tree/master/examples/pwa) for more inspiration.\n\n```ts\nimport useSWRV, { LocalStorageCache } from 'swrv'\n\nfunction useTodos () {\n  const { data, error } = useSWRV('/todos', undefined, {\n    cache: new LocalStorageCache('swrv'),\n    shouldRetryOnError: false\n  })\n\n  return {\n    data,\n    error\n  }\n}\n```\n\n### Serve from cache only\n\nTo only retrieve a swrv cache response without revalidating, you can set the fetcher function to `null` from the useSWRV call. This can be useful when there is some higher level swrv composable that is always sending data to other instances, so you can assume that composables with a `null` fetcher will have data available. This [isn't very intuitive](https://github.com/Kong/swrv/issues/148), so will be looking for ways to improve this api in the future.\n\n```ts\n// Component A\nconst { data } = useSWRV('/api/config', fetcher)\n\n// Component B, only retrieve from cache\nconst { data } = useSWRV('/api/config', null)\n```\n\n### Per-app cache isolation\n\nThe response, in-flight promise, and ref caches are module singletons, shared by every `useSWRV`\ncall in the process. That is what you want in an application, and what you do not want in a test\nsuite: mounts share cache entries, so a later test can be served an entry left behind by an\nearlier one and its own fetcher never runs — silently, as stale data rather than an error.\n\n`provideSwrvCache` gives an app its own set of caches. Every `useSWRV` call within that app's\ncomponent tree uses them instead of the singletons; apps without a provide are unaffected.\n\n```ts\nimport { provideSwrvCache } from 'swrv'\n\nconst app = createApp(App)\nprovideSwrvCache(app)\n```\n\nPass `overrides` to swap in your own cache implementation for any of the three. Anything omitted\ngets a fresh instance.\n\n```ts\nconst bundle = provideSwrvCache(app, { data: new LocalStorageCache('swrv') })\n```\n\nCalling it again on the same app is a no-op and returns the original bundle, so it is safe for a\nhost app and a test harness to both call it. Passing `overrides` on that second call throws\nrather than discarding them — `overrides` replaces an implementation, so it only applies to the\ncall that creates the bundle.\n\nTo seed entries into a bundle, or to inspect what was cached, reach for the bundle itself rather\nthan `overrides`. `getSwrvCache` returns it for an app that has one:\n\n```ts\nimport { getSwrvCache } from 'swrv'\n\ngetSwrvCache(app)?.data.set('/api/user', { data: user }, 0)\n```\n\n#### In test suites\n\nAdd the setup module to your test runner's setup files. Every component mounted through\n`@vue/test-utils` then gets its own caches, with no per-test or per-mount wiring. Seed a test's\ncaches through `getSwrvCache`, which reads the bundle the setup module already provided:\n\n```ts\n// vitest.config.ts\nexport default defineConfig({\n  test: {\n    setupFiles: ['swrv/testing'],\n  },\n})\n```\n\n```js\n// jest.config.js\nmodule.exports = {\n  setupFilesAfterEnv: ['swrv/testing'],\n}\n```\n\n`@vue/test-utils` is an optional peer dependency and is only required if you use this module.\n\nTo wire it up yourself instead — a mount helper, or a runner that isn't test-utils based — use\nthe plugin:\n\n```ts\nimport { swrvCachePlugin } from 'swrv'\n\nmount(Component, { global: { plugins: [swrvCachePlugin] } })\n```\n\nUse `swrvCachePlugin` rather than `{ install: provideSwrvCache }`: Vue calls\n`install(app, ...options)`, so the latter would feed any plugin options into the `overrides`\nparameter.\n\n##### Suites that pass their own cache\n\nA `useSWRV` call passing `config.cache` keeps that cache, which takes precedence over the injected\nbundle. Its dedup and ref caches are still isolated per mount, but its **data** cache is not, so a\nmodule-level cache reaches every test in the run. Give the call a fresh instance per test, or\nreset the one they share.\n\nTo isolate a custom cache instead of resetting it, supply it as the bundle's `data` override at\nmount time and leave that suite off the setup module — global-config plugins install before\nmount-level ones, so the module would already have provided a bundle, and `provideSwrvCache`\nthrows rather than discard overrides:\n\n```ts\nimport { mount } from '@vue/test-utils'\nimport { LocalStorageCache, provideSwrvCache } from 'swrv'\n\nconst withCache = {\n  install: (app) => {\n    provideSwrvCache(app, { data: new LocalStorageCache('swrv') })\n  },\n}\n\nmount(Component, { global: { plugins: [withCache] } })\n```\n\n### Writing to a provided cache\n\nThe standalone `mutate` export writes to the module singletons unless you pass it caches, because\nit is normally called from event handlers and callbacks, where Vue's `inject` is not available.\nInject the bundle in `setup`, where it is, and use it from the handler:\n\n```ts\nsetup () {\n  const cache = inject(swrvCacheInjectionKey)\n  const save = () => mutate('/api/user', next, cache?.data, 0, cache?.refs)\n\n  return { save }\n}\n```\n\n## Error Handling\n\nSince `error` is returned as a Vue Ref, you can use watchers to handle any onError callback functionality. Check out [the test](https://github.com/Kong/swrv/blob/a063c4aa142a5a13dbd39496cefab7aef54e610c/tests/use-swrv.spec.tsx#L481).\n\n```ts\nexport default {\n  setup() {\n    const { data, error } = useSWRV(key, fetch)\n\n    function handleError(error) {\n      console.error(error && error.message)\n    }\n\n    watch(error, handleError)\n\n    return {\n      data,\n      error,\n    }\n  },\n}\n```\n\n## FAQ\n\n### How is swrv different from the [swr](https://github.com/zeit/swr) react library\n\n#### Vue and Reactivity\n\nThe `swrv` library is meant to be used with the Vue Composition API (and eventually Vue 3) so it utilizes Vue's reactivity system to track dependencies and returns vue `Ref`'s as it's return values. This allows you to watch `data` or build your own computed props. For example, the key function is implemented as Vue `watch`er, so any changes to the dependencies in this function will trigger a revalidation in `swrv`.\n\n#### Features\n\nFeatures were built as needed for `swrv`, and while the initial development of `swrv` was mostly a port of swr, the feature sets are not 1-1, and are subject to diverge as they already have.\n\n### Why does swrv make so many requests\n\nThe idea behind stale-while-revalidate is that you always get fresh data eventually. You can disable some of the eager fetching such as `config.revalidateOnFocus`, but it is preferred to serve a fast response from cache while also revalidating so users are always getting the most up to date data.\n\n### How can I refetch swrv data to update it\n\nSwrv fetcher functions can be triggered on-demand by using the `mutate` [return value](https://github.com/Kong/swrv/#return-values). This is useful when there is some event that needs to trigger a revalidation such a PATCH request that updates the initial GET request response data.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tr>\n    <td align=\"center\"><a href=\"https://guuu.io/\"><img src=\"https://avatars2.githubusercontent.com/u/5770711?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Darren Jennings</b></sub></a><br /><a href=\"https://github.com/Kong/swrv/commits?author=darrenjennings\" title=\"Code\">💻</a> <a href=\"https://github.com/Kong/swrv/commits?author=darrenjennings\" title=\"Documentation\">📖</a></td>\n    <td align=\"center\"><a href=\"https://atinux.com\"><img src=\"https://avatars2.githubusercontent.com/u/904724?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Sébastien Chopin</b></sub></a><br /><a href=\"https://github.com/Kong/swrv/commits?author=Atinux\" title=\"Code\">💻</a> <a href=\"#ideas-Atinux\" title=\"Ideas, Planning, & Feedback\">🤔</a></td>\n    <td align=\"center\"><a href=\"https://github.com/chuca\"><img src=\"https://avatars0.githubusercontent.com/u/864496?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Fernando Machuca</b></sub></a><br /><a href=\"#design-chuca\" title=\"Design\">🎨</a></td>\n    <td align=\"center\"><a href=\"https://zeit.co\"><img src=\"https://avatars0.githubusercontent.com/u/14985020?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>ZEIT</b></sub></a><br /><a href=\"#ideas-zeit\" title=\"Ideas, Planning, & Feedback\">🤔</a></td>\n    <td align=\"center\"><a href=\"https://www.adamdehaven.com\"><img src=\"https://avatars.githubusercontent.com/u/2229946?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Adam DeHaven</b></sub></a><br /><a href=\"https://github.com/Kong/swrv/commits?author=adamdehaven\" title=\"Code\">💻</a> <a href=\"https://github.com/Kong/swrv/commits?author=adamdehaven\" title=\"Documentation\">📖</a> <a href=\"#maintenance-adamdehaven\" title=\"Maintenance\">🚧</a></td>\n  </tr>\n</table>\n\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","publish_time":1602509823359,"_cnpm_publish_time":1602509823359,"dist-tags":{"latest":"1.3.0","legacy":"0.9.6","v2-latest":"0.10.0","vue-3-alpha":"1.0.0-beta.11"}}