{"_id":"@kaliber/use-observed-ref","_rev":"44-f569e4daf99829c75d412d487d81e144","name":"@kaliber/use-observed-ref","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@kaliber/use-observed-ref","version":"1.0.0","keywords":["react","hooks","hook","observer"],"license":"MIT","_id":"@kaliber/use-observed-ref@1.0.0","maintainers":[{"name":"joostkiens","email":"me@joostkiens.com"},{"name":"pkuepers","email":"pkuepers@kaliber.net"},{"name":"daveykropf","email":"davey@kaliber.net"},{"name":"eecolor","email":"eecolor@gmail.com"}],"dist":{"shasum":"5616fdeb04059be7c3ae7427829d66696f410aee","tarball":"https://registry.npmjs.org/@kaliber/use-observed-ref/-/use-observed-ref-1.0.0.tgz","fileCount":5,"integrity":"sha512-a7ivIxhcUZ3Ytk9dtbLKPFZV9rFOVGCkVIwHpvjjd1+dJA3MZ3aBHPbORoYB/gYoI7zUvGAkPEPLPJuQuRFZ3Q==","signatures":[{"sig":"MEUCIQCrKSvxQKR0YlAs9kQjMyG+P0mFT0aUoXuFhaD/r+LEpgIgKBGBLOy2qBtEc+I45PokZca6k/U/rjyDiCLTq7kZ02g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3656,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedN1tCRA9TVsSAnZWagAAwjEP/j47+IQIa/tssXYqFcse\nBzAiHol8qWAEBQtA0knFANinnOCfzE78h9qOqfPHNxIlJCeOj6EFKNYZyFWK\nrDC/CdBqEE5pKrS0hBHH/K2uLnf1tZu4pztKCT6Ct853J6fQLe7NDDOo0w+m\nX0FCzsQVWfDT9zXdjjkcT4LOkte3Qz5x+oqLKzkd9nKrJ8AGs2RSF0PDZ52i\n68JePmeQobl7t04qPgw1uHDrGjtK3Y9ycIMh1CyqZKA5EkC3XmXhNw3YvZAD\nD0BU8RXruEdNYLotQoaKLBH1QJiww0xTSRrItV+o/q4TWzU9r3VxR09nP9qN\nRS4ov6/63xPCaXu9cJ4M3tfvINV3ZwfI/uSVGFCCKdvVe+ZrsVItw45w+tD4\nYU3/G7G83cjbVuZyJMuZI0XfUcDSbMca5qEFdo4yup4m8euEgLt0NSytQsY1\nNBxdTM/bgWOW9k/Q6TbJ7F4+g/VAFwm+Czk/qBvB7wnZyfX55FNYM8Fw4bBh\np3JQ9DhkKkFdbpgVUmfo0x3pO2CYEZat0SlJcBboEyURzbxlry/Mpbq5urjN\nutyEnlMrPyxBRGnTkh69XHiDAHqINpQJ60Ir4If5OViMh0HOj/CphLOfIzHs\nLcvpMfAzim/gvREIV8RXwVUowhmJ+Hhe/lm/1mEg6g58XNm1pHzcd3TY3c++\nDnIG\r\n=WInE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","private":false,"_npmUser":{"name":"pkuepers","email":"pkuepers@kaliber.net"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"https://github.com/kaliberjs/use-observed-ref.git","type":"git"},"description":"This is an internal library to facilitate the use of Observers in hooks.","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2019 kaliber.js\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","sideEffects":false,"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/use-observed-ref_1.0.0_1584717164736_0.2303701280976902","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-03-20T15:12:44.532Z","modified":"2026-09-09T12:43:45.813Z","1.0.0":"2020-03-20T15:12:44.840Z"},"license":"MIT","keywords":["react","hooks","hook","observer"],"repository":{"url":"https://github.com/kaliberjs/use-observed-ref.git","type":"git"},"description":"This is an internal library to facilitate the use of Observers in hooks.","maintainers":[{"email":"davey@kaliber.net","name":"daveykropf"},{"email":"ewestra@kaliber.net","name":"eecolor"},{"email":"jduijm@kaliber.net","name":"jerryduijm"},{"email":"development@kaliber.net","name":"kaliber-owner"},{"email":"nhoenderop@kaliber.net","name":"nhoenderop"},{"email":"jbrunemann@kaliber.net","name":"janbru"},{"email":"asmit@kaliber.net","name":"albertkaliber"},{"email":"mvanbrakel@kaliber.net","name":"mvanbrakel"},{"email":"Rvanschaik@kaliber.net","name":"r0h-oh"},{"email":"claan@kaliber.net","name":"1cln"},{"email":"mreimus@kaliber.net","name":"maart-22"},{"email":"ldavidsondescelles@kaliber.net","name":"yoreljenkins"},{"email":"mdevalk@kaliber.net","name":"mdevalk1983"},{"email":"guido.evertzen@gmail.com","name":"guido.evertzen"},{"email":"svroom@kaliber.net","name":"svroom-kaliber"},{"email":"tomharms93@proton.me","name":"tomharms"},{"email":"rinus.vh@hotmail.com","name":"rinus.vh"},{"email":"pgoddijn@gmail.com","name":"pgoddijn"},{"email":"jvankralingen@kaliber.net","name":"jvankralingen"}],"readme":"# useObservedRef\nThis is an internal library to facilitate the use of Observers in hooks\n\n## Installation\nYou typically don't use this library directly.\n\n## Usage\n```jsx\nimport { useObservedRef } from './use-observed-ref'\n\nexport function useObserver() { \n  const [state, setState] = React.useState(null)\n  const createObserver = React.useCallback(\n    () => {\n      // @ts-ignore\n      return new window.Observer(([entry]) => {\n        setState(entry)\n      })\n    },\n    []\n  );\n\n  const reset = React.useCallback(() => { setState(null) }, [])\n  const ref = useObservedRef({ createObserver, reset, disabled: false })\n\n  return { state, ref }\n}\n```\n\nYou can use the disabled option if you want to disable the Observer entirely after a successful callback. E.g.: you want to test if something enters the viewport, but don't to know when it leaves again.\n\n![](https://media.giphy.com/media/3orieUe6ejxSFxYCXe/giphy.gif)\n\n## Disclaimer\nThis library is intended for internal use, we provide __no__ support, use at your own risk. It does not import React, but expects it to be provided, which [@kaliber/build](https://kaliberjs.github.io/build/) can handle for you.\n\nThis library is not transpiled.\n","readmeFilename":"readme.md"}