{"version":"0.10.6","type":"module","types":"./dist/types/index.d.ts","main":"./dist/cjs/production/index.cjs","module":"./dist/esm/production/index.mjs","exports":{".":{"development":{"require":"./dist/cjs/development/index.cjs","import":"./dist/esm/development/index.mjs"},"require":"./dist/cjs/production/index.cjs","import":"./dist/esm/production/index.mjs","types":"./dist/types/index.d.ts"}},"engines":{"node":">=10"},"license":"MIT","keywords":["pridepack"],"name":"solid-swr-store","devDependencies":{"@types/node":"^18.13.0","eslint":"^8.33.0","eslint-config-lxsmnsyc":"^0.4.8","pridepack":"^2.4.0","solid-js":"^1.6.2","swr-store":"0.10.6","tslib":"^2.5.0","typescript":"^4.9.5"},"peerDependencies":{"solid-js":"^1.2","swr-store":"^0.10"},"scripts":{"prepublish":"pridepack clean && pridepack build","build":"pridepack build","type-check":"pridepack check","lint":"pridepack lint","test":"pridepack test --passWithNoTests","clean":"pridepack clean","watch":"pridepack watch"},"description":"SolidJS bindings for swr-store","author":{"name":"Alexis Munsayac"},"private":false,"repository":{"url":"git+https://github.com/lxsmnsyc/swr-store.git","type":"git"},"homepage":"https://github.com/lxsmnsyc/swr-store/tree/main/packages/solid-swr-store","bugs":{"url":"https://github.com/lxsmnsyc/swr-store/issues"},"publishConfig":{"access":"public"},"typesVersions":{"*":{}},"gitHead":"d13357008c132592ebf51676f02fd83fc5103fb4","_id":"solid-swr-store@0.10.6","_nodeVersion":"19.6.0","_npmVersion":"lerna/6.5.1/node@v19.6.0+x64 (win32)","dist":{"integrity":"sha512-obSyaboDj/KRNxjHPRhsXexctI4oYjp47zEq26hBZ0slfTWHSzGtMtYF8w4cSiNkDJTjvl8a0NfyDO8rEcFBcw==","shasum":"a2e8a8ad8a5bf0d5cc0becf2f47e6337a4829cce","tarball":"http://registry-npm.ywwl.com/solid-swr-store/download/solid-swr-store-0.10.6.tgz","fileCount":13,"unpackedSize":17657,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEg5bWBuqMn15AuRD5Y8bWJGS9RTrEY1SfPUo3wNY8pfAiEAhYZU/qeajHzzXa2GKQxUWt1fw3bSV2eftMcrK/pHgyc="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9LrBACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpUoxAAh214j2NCzvDfJw1+n9SU5nNYEQvroURqNEIBKJYz49LjvpYQ\r\nOEeE3XYkf/kpgrJnmvLxhBsTw0J0aion2KxfKuYd4enMhJBG5LDFS5n/fjx7\r\nQzfzvTd3s015GFmoAZizpT1uY9EJ4MMu8zVv5MzIoA8DgdTizuVS/OaO/+zO\r\neJzJDek8TsbOoeHZl8qjl9sjHT5yrf/VYVOTxaEFMnuvPBvxrPmvzAKiyVso\r\nZXpzba8YSGy6MGtqHRAyzP4UZqSjzk6c6yI87SOQ9tjgHPt21Jg0qcgYeZ0o\r\nku41W17Q9F4P36bxkLaLqGOe/abYPjjk5aAn8OaczGQld8irz/Cc1mQkC71H\r\n7PimB4nEuyB3f415u2IzgXakk+MpSdehHvDttNtaT6Ri5gDLHFZkl6NRhD3s\r\n17eEWKUTo8noESNuGHhzQMcPCz1rX5T0UFFqiC9ai0i+3JDZsQ+DoFbSU7HQ\r\ndvSCd2ZdnsL1PTsFnNHMKaxa9kfzOXcRHBQcFauH8w7y2vfbl7Fvci4sdioQ\r\nxFPPPKQhaNCRR/HM/rr/u3q/mlUT68vcCZL+CoVJvu/ZtLRChOdr46cnC/+A\r\ntQDYc8uIH3xwy/hsY1kqDQXYC3Q9R3D/9+Jah9RJo+gRX9D3WbS8IAhvBB01\r\ndsR+jHbgjfOq2o5N6TZanS3ZDXQveprTRMY=\r\n=oyHx\r\n-----END PGP SIGNATURE-----\r\n","size":5230,"noattachment":false,"key":"/solid-swr-store/-/solid-swr-store-0.10.6.tgz"},"_npmUser":{"name":"lxsmnsyc","email":"alexis.munsayac@gmail.com"},"directories":{},"maintainers":[{"name":"lxsmnsyc","email":"alexis.munsayac@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/solid-swr-store_0.10.6_1676982977715_0.6728777053701278"},"_hasShrinkwrap":false,"readme":"# solid-swr-store\n\n> SolidJS bindings for `swr-store`\n\n[![NPM](https://img.shields.io/npm/v/solid-swr-store.svg)](https://www.npmjs.com/package/solid-swr-store) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://codesandbox.io/s/github/LXSMNSYC/swr-store/tree/main/examples/solid-swr-store)\n\n## Install\n\n```bash\nnpm install --save swr-store solid-swr-store\n```\n\n```bash\nyarn add swr-store solid-swr-store\n```\n\n## Usage\n\n```tsx\nimport { Suspense } from 'solid-js';\nimport { createSWRStore } from 'swr-store';\nimport { useSWRStore, useSWRStoreSuspenselesss } from 'solid-swr-store';\n\nconst API = 'https://dog.ceo/api/breed/';\nconst API_SUFFIX = '/images/random';\n\ninterface APIResult {\n  message: string;\n  status: string;\n}\n\nconst dogAPI = createSWRStore<APIResult, [string]>({\n  key: (breed: string) => breed,\n  get: async (breed: string) => {\n    const response = await fetch(`${API}${breed}${API_SUFFIX}`);\n    return (await response.json()) as APIResult;\n  },\n  revalidateOnFocus: true,\n  revalidateOnNetwork: true,\n});\n\nfunction DogImage(): JSX.Element {\n  const data = useSWRStore(dogAPI, ['shiba']);\n\n  return <img src={data().message} alt={data().message} />;\n}\n\nfunction DogImageSuspenseless(): JSX.Element {\n  const data = useSWRStoreSuspenseless(dogAPI, ['shiba']);\n\n  return () => {\n    const current = data();\n\n    if (current.status === 'pending') {\n      return <h1>Loading...</h1>;\n    }\n    if (current.status === 'failure') {\n      return <h1>Something went wrong.</h1>\n    }\n    return <img src={current.data.message} alt={current.data.message} />;\n  };\n}\n\nfunction Trigger(): JSX.Element {\n  return (\n    <button\n      type=\"button\"\n      onClick={() => {\n        dogAPI.trigger(['shiba']);\n      }}\n    >\n      Trigger\n    </button>\n  );\n}\n\nexport default function App(): JSX.Element {\n  return (\n    <>\n      <Trigger />\n      <div>\n        <Suspense fallback={<h1>Loading...</h1>}>\n          <DogImage />\n        </Suspense>\n        <DogImageSuspenseless />\n      </div>\n    </>\n  );\n}\n```\n\n## API\n\n### `useSWRStore(store, args, options)`\n\nSubscribes to an SWR store, passing `args`, which are received by the corresponding store for data-fetching and cache updates.\n\n`options` has the following properties:\n\n- `initialData`: Allows lazy hydration when reading the store. If the store does not have cache, `initialData` hydrates the cache and attempts a revalidation. If no `initialData` is provided, defaults to store's `options.initialData`.\n- `shouldRevalidate`: If `true`, goes through the revalidation process when reading through the cache. Defaults to `true`.\n\n### `useSWRStoreSuspenseless(store, args, options)`\n\nHas the same API as `useSWRStore` except that it doesn't suspend the reading component.\n\n## License\n\nMIT © [lxsmnsyc](https://github.com/lxsmnsyc)\n","publish_time":1676982977892,"_cnpm_publish_time":1676982977892,"dist-tags":{"latest":"0.10.7"}}