{"_id":"@besync/react-use-graphstore","_rev":"2-4d68f305e0582ff27c7ea988ff82351d","name":"@besync/react-use-graphstore","dist-tags":{"latest":"1.0.8"},"versions":{"1.0.8":{"name":"@besync/react-use-graphstore","version":"1.0.8","main":"dist/cjs/index.ts","module":"dist/esm/index.js","typings":"dist/index.d.ts","ts:main":"src/index.ts","repository":{"type":"git","url":"https://github.com/besync/graphstore"},"author":{"name":"BeSync"},"license":"Apache-2.0","dependencies":{"@besync/graphstore":"^1.0.8","tslib":"^1.9.3"},"devDependencies":{"@berun/dev-scripts":"^2.0.17"},"peerDependencies":{"react":"next"},"publishConfig":{"access":"public"},"scripts":{"prebuild":"berun-dev clean","build":"berun-dev build && berun-dev build -- -m CommonJS --outDir dist/cjs","prepare":"berun-dev build -- --emitDeclarationOnly","test":"berun-dev test --env=jsdom","coverage":"berun-dev test --env=jsdom --coverage","prepublishOnly":"yarn lint && yarn build","lint":"berun-dev lint"},"gitHead":"e615349a58c02e387768ee15044fbda237c6818b","description":"## About","_id":"@besync/react-use-graphstore@1.0.8","dist":{"shasum":"a2377f3efa739afdacba024f5b73a6460896cec7","integrity":"sha512-TFl2H6dgFj5sGCPdcNMgvouKGq+Nj34V114DtAkr2VPYIxcBbXHPIjppiRncfOSNcRgYNhzN8K33CKQXYRY1ZQ==","tarball":"https://registry.npmjs.org/@besync/react-use-graphstore/-/react-use-graphstore-1.0.8.tgz","fileCount":27,"unpackedSize":27338,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb51TMCRA9TVsSAnZWagAArr0P/j/EjHMGpeXP+w3f+kdH\nR9sRpGqdWItc+9tPQosWfK5Xmo0MNpjiA2e7EY/gGkTUzBjf7iDNLUyjE5rq\nz8sJUk+R9GwwDoRR3NEy/ygQcJ/I3FzoQcVfBwuVjvo/hMy/TATPx1rgjwTH\ncgnAfc4BucZ7YGORMOxVoOT4iavDra1yjvOb1ZsHeUW2Y/nctH/flNMgnbi7\nKJvlSkEz6/xnBwWMymt+b45j3oxN4+OTGStmD+7ZIHxC0aELin74kUsX6lN8\nipSI2F124WxVt6BW7rntaV5FyzNFXf3eySDvuu2ipFYq3YkupqXP2L3Dt+an\n23dhHVRQn9xoRaCCRLA91176C8jqo3EZu2/9CmMAh4OfzYpS/zefs0LHpq+3\nr9TG2dRnCToyb7T69jRPwg7+ha3wqAqCfRwySP+UN6b9HEAoKREIoHMrigWJ\nBuk56KlG5MbZhrtgmwvl4BQPMoN8PS+ApWOpsGkmasYTeWu11aYFx3XB/cNM\nlN3nuAFtuR6IKJRphAQkVsQvX3SRDnqoR3VOFQYjuzsgfjqY/w0KQYDHB58V\nqUBXoM956nPXXwF8m6oGurO8zQh1GRDFg8OHMbgNUbBQGWiTxVXXPYIjIHr5\nm29KIs5ih4QcxpbDj8lFvSz3kFAacRc6n4LHAFQ5JyxwQnoszDWJg7zipUDw\n7GJ4\r\n=/oqP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA3FcUpH1Hwp5YwTFgnK4fM5fpEcOcqquNrzw0GyXSCDAiEA0VEsOl8QY06r5eY2OWawdjGOQ5HPSgJ9mqabvMr63Dc="}]},"maintainers":[{"name":"guycreate","email":"guy@nodekit.io"}],"_npmUser":{"name":"guycreate","email":"guy@nodekit.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-use-graphstore_1.0.8_1541887179711_0.7243711169341003"},"_hasShrinkwrap":false}},"time":{"created":"2018-11-10T21:59:39.666Z","1.0.8":"2018-11-10T21:59:39.815Z","modified":"2022-04-04T18:33:58.540Z"},"maintainers":[{"email":"admin@tinia.org","name":"tinialabs1"},{"email":"guy-nodekit@barnardmail.net","name":"guycreate"}],"description":"## About","repository":{"type":"git","url":"https://github.com/besync/graphstore"},"author":{"name":"BeSync"},"license":"Apache-2.0","readme":"# React Hook for GraphStore\n\n## About\n\nThis is a light-weight React Hook for for using observable state, backed by a local global store and/or a remote databasem in a React function component\n\nOptionally includes a zero-configuration, batteries included, runner for Webpack that adds decorator syntax to Babel.\n\n## Features\n\n- Written for modern (2019+) React\n- Use observable GraphStore features with two line setup\n- includes definitions for memory store\n- roadmap: definitions for Firebase realtime database and Firestore\n- Typescript definitions included\n- No component classes or separate state manager required, pure React Hooks that can be used in function components\n\n## Requirements\n\nReact 16.7 or later\n\n## installation\n\n```bash\n$ npm install @besync/react-use-graphstore\n```\n\n```js\nimport { useGraphStoreMemory } from ' @besync/react-use-graphstore'\n```\n\n```js\nimport { observer, useOnce } from '@besync/react-use-graphstore-channel'\n```\n\n```js\nimport { Observer, useOnce } from '@besync/react-use-graphstore-channel'\n```\n\n## Usage: Root component and observer\n\n```js\nimport { useGraphStoreMemory, Observer } from '@besync/react-use-graphstore'\n\nconst { initialState, stores } from '...'  // your model\n\nconst App = props => {\n\n  const store = useGraphStoreMemory(initialState)\n  const post = useOnce(() => stores.PostStore.getbyId('1'))\n\n  return (\n    <Observer>\n      {() => (\n        <div>\n          HELLO {post.title}\n        </div>\n      )}\n    </Observer>\n  )\n}\n```\n\n## Usage: another component\n\n```js\nimport { useGraphStoreMemory, Observer } from '@besync/react-use-graphstore'\n\nconst { stores } from '...'  // your model\n\nconst Component = props => {\n\n  const post = useOnce(() => stores.PostStore.getbyId('1'))\n\n  return (\n    <Observer>\n      {() => (\n        <div>\n          HELLO AGAIN {post.title}\n          <button onClick={() => { post.title = 'UPDATED' }} />\n        </div>\n      )}\n    </Observer>\n  )\n}\n```\n\n## Webpack Build\n\nYou need to make sure there are two separate entry points in Webpack (one for the main\njavascript, one for the iFrame specific javascript) and two separate HTML files created by the HTML Plugin.\n\nThe simplest way to do this is with [`@breun/scripts`](https://github.com/bestyled/berun):\n\n### @berun configuration\n\n```js\n// config/berun.config.js\nmodule.exports = {\n  use: [\n    '@berun/preset-react',\n    '@berun/runner-eslint',\n    require('@besync/react-use-graphstore/berun')\n  ]\n}\n```\n\n`package.json`\n\n```json\n{\n  \"scripts\": {\n    \"start\": \"berun-scripts start\",\n    \"build\": \"berun-scripts build\",\n    \"format\": \"berun-scripts lint\",\n    \"test\": \"berun-scripts test --env=jsdom\",\n    \"eject\": \"berun-scripts eject\"\n  },\n  \"dependencies\": {\n    \"react\": \"next\",\n    \"react-dom\": \"next\",\n    \"@besync/react-use-graphstore\": \"...\"\n  },\n  \"devDependencies\": {\n    \"@berun/scripts\": \"...\",\n    \"@berun/preset-react\": \"...\",\n    \"@berun/runner-eslint\": \"...\"\n  },\n  \"resolutions\": {\n    \"babel-core\": \"^7.0.0-bridge.0\"\n  }\n}\n```\n\n## Prior Art\n\n- `@besync/graphstore` - Used to provide the observable store in both parent and worker childs; query the store using a simple Document/Collection based interface, then get and set properties on the underlying result with auto-refresh whenever the underlying store changes (locally, in child worker, or remotely)\n- `@bestyled/berun` - Used to provide a zero configuration, batteries included, Webpack build, similar to `create-react-app`\n- `react-use` - Used as inspiration for the React Hooks introduced in React 16.7; not used as a dependency\n- `useState`, `useRef`, and `useEffects` introduced in React 16.7\n\n## License\n\nApache 2.0\n","readmeFilename":"README.md"}