{"version":"0.10.3","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.19.0","eslint-config-lxsmnsyc":"^0.4.7","pridepack":"^2.0.1","solid-js":"^1.4.7","swr-store":"0.10.3","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":"b55bba89e7149b77aab158cf2693ae912ad0b642","_id":"solid-swr-store@0.10.3","_nodeVersion":"16.8.0","_npmVersion":"lerna/5.1.8/node@v16.8.0+x64 (win32)","dist":{"integrity":"sha512-0uc67ipjBz7vlusDrZwrS90kx24SVmrw9jnJ4lC0eU1xKOm+JUyoS8xva97e2a6KtULcYYJjWOgf4o8YDw+bLQ==","shasum":"577299b53ecfe1914a84220ef9153fcd4eb5b162","tarball":"http://registry-npm.ywwl.com/solid-swr-store/download/solid-swr-store-0.10.3.tgz","fileCount":13,"unpackedSize":21714,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC4GiiPKYkLNZ8QsRf1pdI/ptEDsIX9tVEcX7CBvuAs3AIhANir8pV4K1rB8HRPwZpzZubMGwOZuDyIZ+SPJq6/mjXN"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi16yBACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpK+A//SXa/ngmKgFQAP6LAd8h0lWVS+Fiwv0eFw0Rx8p2ZDBB9u6uR\r\n1n5a0wp7Op6BtTn1b5blMZ8qzdjaB4rFkcXG+f6/prRoiO4dU9vqwuhHuxYP\r\nTNztMDI8kkiUAIw6OONjDFCf1vz0eWtZf9r2/v8mSXO9mghkZA8tuFxvOZBg\r\nSKwxfx4ZmJ0N5HCWQjxOJLoNWvfspEcsGivaIMv4mV6XSun6yok2oK6nl/aS\r\n7/Ol+FMDh1OwLDa7EvWFXfnDCkXoTUtePORxWKqVsNJ1hHtqIAHmFRAjGD74\r\nWkm48gEhD8cdiayHH1zKrO4O7pUfAo7bWHgSu73KSRKF022MK5yJj4qYeTuR\r\nWGhs4JGlIZXvFv//4Gptfjqt35V6K+B1PpH7p1HMoKJkaosw2XgStheUCCOI\r\nmI+ApsVRO4IQYlsXmbkr964r2iyA83fWimMeNGSTV8HyBUAJeooZbCJgI3Sx\r\nDvRk1FbZpv5HCSbTQ7lSZCtt8fySxwU4mi/+/ZJRxfMoyzofekiS9jZ4wTql\r\nLuMQBgILE+jRNw5Gn/So+pGZ5NrcEwDtCo7oGvZquzzrI8C8G21zz6/a+VcC\r\nhe8NoSfsg2ih5BprKHNVVNuKWK/g7igwHg9UheF84fJT2mUj+fwdRWtbEYpR\r\nsTg1e8NlO5q1oTMVCL/9a8obe4wGuuWsPiY=\r\n=QnyX\r\n-----END PGP SIGNATURE-----\r\n","size":5544,"noattachment":false,"key":"/solid-swr-store/-/solid-swr-store-0.10.3.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.3_1658301569346_0.5738607476535356"},"_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":1658301569732,"_cnpm_publish_time":1658301569732,"dist-tags":{"latest":"0.10.7"}}