{"version":"0.10.4","types":"dist/types/index.d.ts","main":"dist/cjs/production/index.js","module":"dist/esm/production/index.js","exports":{".":{"development":{"require":"./dist/cjs/development/index.js","import":"./dist/esm/development/index.js"},"require":"./dist/cjs/production/index.js","import":"./dist/esm/production/index.js","types":"./dist/types/index.d.ts"}},"engines":{"node":">=10"},"license":"MIT","keywords":["pridepack"],"name":"solid-swr-store","devDependencies":{"@types/jest":"^27.0.1","@types/node":"^17.0.9","eslint":"^8.20.0","eslint-config-lxsmnsyc":"^0.4.8","pridepack":"^2.1.2","solid-js":"^1.4.7","swr-store":"0.10.4","tslib":"^2.4.0","typescript":"^4.7.4"},"peerDependencies":{"solid-js":"^1.2","swr-store":"^0.9"},"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":{"*":{"*":["./dist/types/index.d.ts"]}},"gitHead":"ae7ea141fa647ad77cf76e701769d73bfe40aad7","_id":"solid-swr-store@0.10.4","_nodeVersion":"16.8.0","_npmVersion":"lerna/5.1.8/node@v16.8.0+x64 (win32)","dist":{"integrity":"sha512-ohjJuQh8mATbYdp3zotqcPoFNfwHo1+ssO5L2oXeYnuUAoplDWuuRo/rUcy1bFRzaliZbCfpUdBPDTpGhZcgzg==","shasum":"4b964e2911787cc249483cf67b1f8042de043f39","tarball":"http://registry-npm.ywwl.com/solid-swr-store/download/solid-swr-store-0.10.4.tgz","fileCount":13,"unpackedSize":16740,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDJmRi1CD0aPir1peGbfzLzYihLgwuytl06x5C1fzuqTAIgOIbTBMQxR4yBZ/0hAchn8oWHcRLpVZnG9Go9Icr0mzk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi4oSVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoFFBAAjep2f39mvKOxWb6EFZLiJ/+jWBmHm9g4p9suM+zwYmyuU4nS\r\nkd7h8c63et0+r81Xt+oi4FobNpMEPY2vo/Jx322LwSriBtYmlBbR5Ek+rx2D\r\nl6AntuHDcMvOkYfPrtQTrhA0O6JO+xKUZTq//hWvRWGnukC2FJEZad6996Tf\r\nx+h8isiOiUsF+RcH+5FQJKum/dut574JUgRJ1uaYAV0f0t1XcMsLqjSt/7Is\r\nCe9jNll/fIthitNwraUx55EEDrqFK5bhmBy6I/EVeBMXa3bIyq1PuvFUwBmt\r\nl45e5aEw3H4jBjFJGM2WKiA77zLI52rZWWkAC9rKjEeqddzMuUQttL4gxE2w\r\nX270GusK/7hWzySpTddwcPgYgO6ew5rXFev05+1cDApu66vxWvyc/0OWbHSF\r\nwnnn5tXZZ6CS+PMthNPP23grfMzGTeIqkRu4++6yhTskdLwePK0gNlyGFJ/z\r\nfLaFNk1HNHiwmhJ28ZJl33CTxnWSrDU3IMllxyXl7vHZLXACLJpmY1bJvX/m\r\njKniUHkQ/C3iS/P/WxAxHSnSPIlGPciBKPq/keP6TMTe5SCnASFyFn7PDy17\r\ncLoOBFaevmPIKaDIqHi2Mio9aW1zUF/XPcKiKn3KKFfYnEJ2SyyM6Y1+MCN0\r\nJyqpGKopQvHMojL7ijY5UycHCTUlUcgoGoc=\r\n=iK/M\r\n-----END PGP SIGNATURE-----\r\n","size":5078,"noattachment":false,"key":"/solid-swr-store/-/solid-swr-store-0.10.4.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.4_1659012244954_0.151667385635609"},"_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":1659012245122,"_cnpm_publish_time":1659012245122,"dist-tags":{"latest":"0.10.7"}}