{"_id":"@abiskup/use-global-state","_rev":"3-877738ab98a9cbc236456e326aff71ae","name":"@abiskup/use-global-state","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@abiskup/use-global-state","version":"0.0.1","description":"ts-rest-react is very small and simple package which provides 2 things: 1. A react hook for managing requests 2. A react wrapper component for automatic pending and error indication.","main":"lib/index.js","scripts":{"build":"tsc"},"repository":{"type":"git","url":" "},"dependencies":{"@types/react":"^16.8.12"},"peerDependencies":{"react":"^16.8.12"},"keywords":["state","react","hooks"],"author":{"name":"Alexander Biskup"},"license":"ISC","devDependencies":{"typescript":"^3.4.2"},"_id":"@abiskup/use-global-state@0.0.1","_nodeVersion":"10.8.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-SR1AWWUtj6mHOYlQez4wmk/GdQW9rcYDrrFr5nuyOmT+2q3m2Ptrlgp0axecSFkEtqX8r7mNT2f1WD+CR158iw==","shasum":"f9b211c6b31391f285d4e7801e6b2d569ab60140","tarball":"https://registry.npmjs.org/@abiskup/use-global-state/-/use-global-state-0.0.1.tgz","fileCount":13,"unpackedSize":17234,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcxym/CRA9TVsSAnZWagAAAoYP/jEdyrpFXuqLwVxcoeSF\nUJF6xgol1vao4Tbc5y2cbrpFfjRQL1bUaThNlkU86ZUtyhFfLHKUocQm4QIG\nmCHp4xu+bzIFuq53pSoTcBiEiOacZPwTYoIpZUe1m6OoKuc6fxGpiGaaU2wM\niJaLLQPEVYHMh5AEuI7LaBtRYUr/+fq8mZAzZdrId+MGzYqAIHLcfIEpuU2p\nLd9qNtSt0VI5ns8Ccrr6K78KqAC4MTZpsmWCi1KgSAvEZzgzIkJ4mz8KLIzh\nODUpibTJFHEFCDmrMDLKqDz0dJX8l6QinCASPVTTRPI37RAAsMcSSJ+41jDf\nO1viDkSRIue1K2Ob+1dworihqs54gBiiakwcLrvGRo+RWuWYe0PMbchpzLIl\nZMcObNQOVMo6pI3fVTQbu18r0p/F78kSi8zKTzM5HLOZ6YwZmK8BUAzfjNNF\n5320U5hFnnRUWZdvA62NJPpe2W6YlXFRfLDHiyIwWTeKeqF3S1x1sJBSaQBw\nJLkw/1oOBoZc3j00VEcEU90k6M8xsfqSX7vX/2VVeOeWoSPJQanJYjElpkU3\nqqewTml2d9yvd8g8kJhU7rialPtyQcxfqh95ZSuzSMfre2sZihKssGI9qpo8\n3u4XisUBhgRRK1R9f681pU27btmSltNZYDDLNrQbcfLjJ5XfqNrKCrbK9Rmv\nKe71\r\n=777y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC1cEw9WOFBJ7+KhY5sYKdJGDCa/jEpM9xjbwdKhEDFOwIgXk7XYtQZkaF9wgPIde8s4b69hua/yR4ueOuT7ItZ63w="}]},"maintainers":[{"name":"abiskup","email":"alexander.biskup.at@gmail.com"}],"_npmUser":{"name":"abiskup","email":"alexander.biskup.at@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-global-state_0.0.1_1556556222913_0.76069452278129"},"_hasShrinkwrap":false,"deprecated":"deprecated"},"0.0.2":{"name":"@abiskup/use-global-state","version":"0.0.2","description":"is a react-hook for using one or multiple global states in react components.","main":"lib/index.js","scripts":{"build":"tsc"},"repository":{"type":"git","url":" "},"dependencies":{"@types/react":"^16.8.12"},"peerDependencies":{"react":"^16.8.12"},"keywords":["state","react","hooks"],"author":{"name":"Alexander Biskup"},"license":"ISC","devDependencies":{"typescript":"^3.4.2"},"_id":"@abiskup/use-global-state@0.0.2","_nodeVersion":"10.8.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-vgUjiKsMkj7xmYEFgBSxKMarJB9uq4KBZ8GMa/hNhWfAvxs4xOp6+GfdkLZtA5hCRRfcIwpOZz1+u9Lr1V7FKQ==","shasum":"65e0a50cbb3ebe6ea9a80e6bd7f90dc97db73b52","tarball":"https://registry.npmjs.org/@abiskup/use-global-state/-/use-global-state-0.0.2.tgz","fileCount":13,"unpackedSize":15535,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcxy2YCRA9TVsSAnZWagAAMcwQAIEsb0BKlGWpo0PMh4l8\nXnPhbBpPedZRhZzAnCCGneE81CGan/1AToXt0/lGoUBa1ele/2+Bs7YoCom3\nJFvvumz/Ry8h5ggBPUZYOCbsxvRGnUcB7lEQx94rybHUAHEyFH8rDnmshwtE\nMdHATaX9ekg7yx5OkW/GII/7hpgO9PF3qD454fPP8GkdEzXO0StrrJdGRDfS\nmZZadPHeu7UBGnLqR2733tLtcjrLNbkc8rIuu2A+aZD689crPtesH39rUQVj\ni39q7JfpVh7xnRvWAPXgQlw9RQmASpmtgidj8oL1gIKbZ9iKUZyaIKnW5ekO\n+kt6v0U6HRptIVlVgdqJWxQGPhuEuKpPtTwb/RBzXUS/APCMPODIHFJm8FRv\nifEeXfUMv3mvDulPHNaKN685GJiSZloLny0PTP3qa3e4r9+/bP2zkBYi1wts\n4erDoUTS1i/Sva0lhbKk7Vg1pLAMGPCV0gBNzQRqk4hLewvbOxCsF3nART3r\nyujwRE4lyb3n7jPy8EG9IwAlwgJNzLOHfqLi+CMYjFiHhuokWTQp/6RnYYOY\nOMNmi9ZXvOoKMUqnPIPkJD78Un4jSR8eeBGGHDULxaBdx4wwTjkjJfUkZDe3\ntIHQQlxU5YHeGNRTDlP17qKj1hkiGVDkBRcTx88/OQwHzN6s2Od53z6Qdiwl\neR+e\r\n=VJ6k\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID1LOf6r6fA04eWWfa9GESXJlybondYArltF5sTTMFz2AiASpLZdwQXIYEfwF2XJ4UG+E4v9pNQ3tRpahyEggABJNQ=="}]},"maintainers":[{"name":"abiskup","email":"alexander.biskup.at@gmail.com"}],"_npmUser":{"name":"abiskup","email":"alexander.biskup.at@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-global-state_0.0.2_1556557207752_0.5531905360524161"},"_hasShrinkwrap":false,"deprecated":"deprecated"}},"time":{"created":"2019-04-29T16:43:42.723Z","0.0.1":"2019-04-29T16:43:42.997Z","modified":"2022-04-04T10:59:40.917Z","0.0.2":"2019-04-29T17:00:07.924Z"},"maintainers":[{"name":"abiskup","email":"alexander.biskup.at@gmail.com"}],"description":"is a react-hook for using one or multiple global states in react components.","keywords":["state","react","hooks"],"repository":{"type":"git","url":" "},"author":{"name":"Alexander Biskup"},"license":"ISC","readme":"# use-global-state\n\nis a react-hook for using one or multiple global states in react components.\n\n```tsx\nconst SomeComponent = () => {\n\n    const [name, setName] = useGlobalState('name'); \n\n}\n```\n\nuseGlobalState takes one argument which is a key. Every hook call with the same key shares the same data. \n\nWhen, like in this example, using the \"default global state\", all properties are by default of type `any`.\n\nIf you want to use typed, shared data, or want to use an initial state, you need to create your own custom global state.\n\n### Custom global state\nYou can create your own custom global state and use it with hooks in three steps:\n\n```tsx\n\n// 1. create an object which is your initial state\nconst appState = {\n    name: 'Steven',\n    age: 22,\n}\n\n// 2. create a global state with your object\nconst globalAppState = createGlobalState(appState);\n\n// 3. create a hook which uses your global state\nexport const useAppState = createGlobalStateHook(globalAppState);\n\n\n// use it\n\nconst SomeComponent = () => {\n\n    const [name, setName] = useAppState('name');\n    const [age, setAge] = useAppState('age');\n    \n}\n\n```\nThat way name and age are typed and have the initial value you specified. ","readmeFilename":"README.md"}