{"_id":"use-async-memo","_rev":"2838876","name":"use-async-memo","description":"React hook for generating async memoized data.","dist-tags":{"latest":"1.2.4"},"maintainers":[{"name":"awmleer","email":""}],"time":{"modified":"2022-09-06T15:45:58.000Z","created":"2019-06-24T07:19:07.469Z","1.2.4":"2022-04-15T06:52:03.260Z","1.2.3":"2021-04-25T02:30:16.834Z","1.2.2":"2019-09-12T14:48:17.823Z","1.2.1":"2019-09-12T10:14:02.587Z","1.2.0":"2019-06-26T08:01:13.439Z","1.1.0":"2019-06-26T03:18:32.622Z","1.0.0":"2019-06-24T07:19:07.469Z"},"users":{},"author":{"name":"awmleer","email":"awmleer@icloud.com"},"repository":{"type":"git","url":"https://github.com/awmleer/use-async-memo"},"versions":{"1.2.4":{"name":"use-async-memo","version":"1.2.4","scripts":{"build":"gulp prebuild && tsc","test":"jest"},"description":"React hook for generating async memoized data.","keywords":["react","hook","memo","async"],"main":"index.js","repository":{"type":"git","url":"https://github.com/awmleer/use-async-memo"},"author":{"name":"awmleer","email":"awmleer@icloud.com"},"license":"MIT","private":false,"peerDependencies":{"react":"^16.8.0 || ^17.0.0"},"devDependencies":{"@testing-library/jest-dom":"^4.0.0","@testing-library/react":"^8.0.1","@types/jest":"^24.0.15","@types/react":"^17.0.0","@types/react-dom":"^17.0.0","gulp":"^4.0.2","gulp-clean":"^0.4.0","jest":"^24.8.0","react":"^17.0.0","react-dom":"^17.0.0","ts-jest":"^24.0.2","typescript":"^3.5.2","use-debounce":"^2.1.0"},"sideEffects":[],"publishConfig":{"registry":"https://registry.npmjs.org"},"licenseText":"MIT License\n\nCopyright (c) 2019 awmleer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"use-async-memo@1.2.4","dist":{"shasum":"3122eea51645ee56b9ed699eaafcd74af0ad77b0","size":2205,"noattachment":false,"key":"/use-async-memo/-/use-async-memo-1.2.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/use-async-memo/download/use-async-memo-1.2.4.tgz"},"_npmUser":{"name":"awmleer","email":"awmleer@icloud.com"},"directories":{},"maintainers":[{"name":"awmleer","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-async-memo_1.2.4_1650005523132_0.5129916020692107"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-04-15T06:52:08.910Z","publish_time":1650005523260,"_cnpm_publish_time":1650005523260},"1.2.3":{"name":"use-async-memo","version":"1.2.3","scripts":{"build":"gulp prebuild && tsc","test":"jest"},"description":"React hook for generating async memoized data.","keywords":["react","hook","memo","async"],"main":"index.js","repository":{"type":"git","url":"https://github.com/awmleer/use-async-memo"},"author":{"name":"awmleer","email":"awmleer@icloud.com"},"license":"MIT","private":false,"devDependencies":{"@testing-library/jest-dom":"^4.0.0","@testing-library/react":"^8.0.1","@types/jest":"^24.0.15","@types/react":"^16.8.6","gulp":"^4.0.2","gulp-clean":"^0.4.0","jest":"^24.8.0","react":"^16.8.6","react-dom":"^16.8.6","ts-jest":"^24.0.2","typescript":"^3.5.2","use-debounce":"^2.1.0"},"peerDependencies":{"react":"^16.8.0 || ^17.0.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 awmleer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"use-async-memo@1.2.3","dist":{"shasum":"fe49d7ae1cd850199cf9e4a8ee483e31ed85659f","size":2170,"noattachment":false,"key":"/use-async-memo/-/use-async-memo-1.2.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/use-async-memo/download/use-async-memo-1.2.3.tgz"},"_npmUser":{"name":"awmleer","email":"awmleer@sparker.xyz"},"directories":{},"maintainers":[{"name":"awmleer","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-async-memo_1.2.3_1619317816681_0.06020704403209076"},"_hasShrinkwrap":false,"publish_time":1619317816834,"_cnpm_publish_time":1619317816834,"_cnpmcore_publish_time":"2021-12-16T12:33:41.973Z"},"1.2.2":{"name":"use-async-memo","version":"1.2.2","scripts":{"build":"gulp prebuild && tsc","test":"jest"},"description":"React hook for generating async memoized data.","keywords":["react","hook","memo","async"],"main":"index.js","repository":{"type":"git","url":"https://github.com/awmleer/use-async-memo"},"author":{"name":"awmleer","email":"awmleer@sparker.xyz"},"license":"MIT","private":false,"devDependencies":{"@testing-library/jest-dom":"^4.0.0","@testing-library/react":"^8.0.1","@types/jest":"^24.0.15","@types/react":"^16.8.6","gulp":"^4.0.2","gulp-clean":"^0.4.0","jest":"^24.8.0","react":"^16.8.6","react-dom":"^16.8.6","ts-jest":"^24.0.2","typescript":"^3.5.2","use-debounce":"^2.1.0"},"peerDependencies":{"react":"^16.8.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 awmleer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"use-async-memo@1.2.2","dist":{"shasum":"6549579335c00afc0fff6f18eafc4a9d29596ece","size":2156,"noattachment":false,"key":"/use-async-memo/-/use-async-memo-1.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/use-async-memo/download/use-async-memo-1.2.2.tgz"},"maintainers":[{"name":"awmleer","email":""}],"_npmUser":{"name":"awmleer","email":"awmleer@sparker.xyz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-async-memo_1.2.2_1568299697632_0.0024738880731993707"},"_hasShrinkwrap":false,"publish_time":1568299697823,"_cnpm_publish_time":1568299697823,"_cnpmcore_publish_time":"2021-12-16T12:33:42.183Z"},"1.2.1":{"name":"use-async-memo","version":"1.2.1","scripts":{"build":"gulp prebuild && tsc","test":"jest"},"description":"React hook for generating async memoized data.","keywords":["react","hook","memo","async"],"main":"index.js","repository":{"type":"git","url":"https://github.com/awmleer/use-async-memo"},"author":{"name":"awmleer","email":"awmleer@sparker.xyz"},"license":"MIT","private":false,"devDependencies":{"@testing-library/jest-dom":"^4.0.0","@testing-library/react":"^8.0.1","@types/jest":"^24.0.15","@types/react":"^16.8.6","gulp":"^4.0.2","gulp-clean":"^0.4.0","jest":"^24.8.0","react":"^16.8.6","react-dom":"^16.8.6","ts-jest":"^24.0.2","typescript":"^3.5.2","use-debounce":"^2.1.0"},"peerDependencies":{"react":"^16.8.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 awmleer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"use-async-memo@1.2.1","dist":{"shasum":"cb509c10f8e943ae3c517db5f53bddd5b802d9f1","size":3671,"noattachment":false,"key":"/use-async-memo/-/use-async-memo-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/use-async-memo/download/use-async-memo-1.2.1.tgz"},"maintainers":[{"name":"awmleer","email":""}],"_npmUser":{"name":"awmleer","email":"awmleer@sparker.xyz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-async-memo_1.2.1_1568283242429_0.4558740864979054"},"_hasShrinkwrap":false,"publish_time":1568283242587,"_cnpm_publish_time":1568283242587,"_cnpmcore_publish_time":"2021-12-16T12:33:42.430Z"},"1.2.0":{"name":"use-async-memo","version":"1.2.0","scripts":{"build":"gulp prebuild && tsc","test":"jest"},"description":"React hook for generating async memoized data.","keywords":["react","hook","memo","async"],"main":"index.js","repository":{"type":"git","url":"https://github.com/awmleer/use-async-memo"},"author":{"name":"awmleer","email":"awmleer@sparker.xyz"},"license":"MIT","private":false,"devDependencies":{"@testing-library/react":"^8.0.1","@types/jest":"^24.0.15","@types/react":"16.8.x","gulp":"4.0.x","gulp-clean":"^0.4.0","jest":"^24.8.0","jest-dom":"^3.5.0","react":"16.8.x","react-dom":"16.8.x","ts-jest":"^24.0.2","typescript":"^3.5.2","use-debounce":"^2.1.0"},"peerDependencies":{"react":"^16.8.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 awmleer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"use-async-memo@1.2.0","dist":{"shasum":"df6fc503bfd66bfea6b29a79207658d4e6b875cf","size":1868,"noattachment":false,"key":"/use-async-memo/-/use-async-memo-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/use-async-memo/download/use-async-memo-1.2.0.tgz"},"maintainers":[{"name":"awmleer","email":""}],"_npmUser":{"name":"awmleer","email":"awmleer@sparker.xyz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-async-memo_1.2.0_1561536073284_0.7682010837398601"},"_hasShrinkwrap":false,"publish_time":1561536073439,"_cnpm_publish_time":1561536073439,"_cnpmcore_publish_time":"2021-12-16T12:33:42.615Z"},"1.1.0":{"name":"use-async-memo","version":"1.1.0","scripts":{"build":"gulp prebuild && tsc","test":"jest"},"description":"React hook for generating async memoized data.","keywords":["react","hook","memo","async"],"main":"index.js","repository":{"type":"git","url":"https://github.com/awmleer/use-async-memo"},"author":{"name":"awmleer","email":"awmleer@sparker.xyz"},"license":"MIT","private":false,"devDependencies":{"@testing-library/react":"^8.0.1","@types/jest":"^24.0.15","@types/react":"16.8.x","gulp":"4.0.x","gulp-clean":"^0.4.0","jest":"^24.8.0","jest-dom":"^3.5.0","react":"16.8.x","react-dom":"16.8.x","ts-jest":"^24.0.2","typescript":"^3.1.1"},"peerDependencies":{"react":"^16.8.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 awmleer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"use-async-memo@1.1.0","dist":{"shasum":"f6b105dda850b4b17587c3b60a18c338640e97e5","size":1780,"noattachment":false,"key":"/use-async-memo/-/use-async-memo-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/use-async-memo/download/use-async-memo-1.1.0.tgz"},"maintainers":[{"name":"awmleer","email":""}],"_npmUser":{"name":"awmleer","email":"awmleer@sparker.xyz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-async-memo_1.1.0_1561519112519_0.37715194303838384"},"_hasShrinkwrap":false,"publish_time":1561519112622,"_cnpm_publish_time":1561519112622,"_cnpmcore_publish_time":"2021-12-16T12:33:42.854Z"},"1.0.0":{"name":"use-async-memo","version":"1.0.0","scripts":{"build":"gulp prebuild && tsc","test":"jest"},"description":"React hook for generating async memoized data.","keywords":["react","hook","memo","async"],"main":"index.js","repository":{"type":"git","url":"https://github.com/awmleer/use-async-memo"},"author":{"name":"awmleer","email":"awmleer@sparker.xyz"},"license":"MIT","private":false,"devDependencies":{"@testing-library/react":"^8.0.1","@types/jest":"^24.0.15","@types/react":"16.8.x","gulp":"4.0.x","gulp-clean":"^0.4.0","jest":"^24.8.0","jest-dom":"^3.5.0","react":"16.8.x","react-dom":"16.8.x","ts-jest":"^24.0.2","typescript":"^3.1.1"},"peerDependencies":{"react":"^16.8.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 awmleer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"use-async-memo@1.0.0","dist":{"shasum":"c961d0056e7465e823f4393a538cce4aefe191e0","size":1602,"noattachment":false,"key":"/use-async-memo/-/use-async-memo-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/use-async-memo/download/use-async-memo-1.0.0.tgz"},"maintainers":[{"name":"awmleer","email":""}],"_npmUser":{"name":"awmleer","email":"awmleer@sparker.xyz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-async-memo_1.0.0_1561360747358_0.5898053733816362"},"_hasShrinkwrap":false,"publish_time":1561360747469,"_cnpm_publish_time":1561360747469,"_cnpmcore_publish_time":"2021-12-16T12:33:43.052Z"}},"readme":"# useAsyncMemo\n\nReact hook for generating async memoized data.\n\n## API\n\n```typescript\nfunction useAsyncMemo<T>(factory: () => Promise<T>, deps: DependencyList, initial?: T): T\n```\n\nIf `factory` returns `undefined` or `null`, `useAsyncMemo` will leave the memoized value **unchanged**.\n\n## Demo\n\n### Import\n\n```js\nimport {useAsyncMemo} from \"use-async-memo\"\n```\n\n### Fetch API:\n\n```js\nconst data = useAsyncMemo(doAPIRequest, [])\n```\n\nor\n\n```js\nconst data = useAsyncMemo(() => doAPIRequest(), [])\n```\n\nor\n\n```js\nconst data = useAsyncMemo(() => {\n  return doAPIRequest()\n}, [])\n```\n\nor\n\n```js\nconst data = useAsyncMemo(async () => {\n  return await doAPIRequest()\n}, [])\n```\n\n### Search on inputting:\n\n```js\nconst [input, setInput] = useState()\nconst users = useAsyncMemo(async () => {\n  if (input === '') return []\n  return await apiService.searchUsers(input)\n}, [input], [])\n```\n\n### Get loading status:\n\n```js\nconst [loading, setLoading] = useState(true)\nconst data = useAsyncMemo(async () => {\n  setLoading(true)\n  const response = await doAPIRequest()\n  setLoading(false)\n  return response\n}, [])\n```\n\n### With ability of manual clearing:\n\n```js\nconst [input, setInput] = useState()\n\nconst [clearFlag, setClearFlag] = useState({\n  val: false\n})\nfunction clearItems() {\n  setClearFlag({\n    val: true\n  })\n}\n\nconst users = useAsyncMemo(async () => {\n  if (clearFlag.val) {\n    clearFlag.val = false\n    return null\n  }\n  if (input === '') return []\n  return await apiService.searchUsers(input)\n}, [input, clearFlag], [])\n```\n\n### With debounced value:\n \n> see [use-debounce](https://github.com/xnimorz/use-debounce)\n\n```js\nconst [input, setInput] = useState()\nconst [debouncedInput] = useDebounce(input, 300)\nconst users = useAsyncMemo(async () => {\n  if (debouncedInput === '') return []\n  return await apiService.searchUsers(debouncedInput)\n}, [debouncedInput], [])\n```\n\n","_attachments":{},"license":"MIT"}