{"version":3,"sources":["../../src/useWithoutLoading/index.ts"],"names":["useMemo","_subscribeWithError","createSubscribeWithError","_root","_callbacks","_load","_subscribeWithLoad"],"mappings":";;;;;AASA,IAAM,iBAAA,GAAoB,CACxB,KAEA,KAAAA,aAAA;AAAA,EACE,MACE,MAAO,CAAA,MAAA,CAAO,KAAO,EAAA;AAAA,IACnBC,CAAqB,EAAA;AAAA,MACnB,KAAO,EAAAC,0CAAA;AAAA,QACL,MAAMC,CAAMC,CAAAA,CAAAA;AAAA,QACZ,MAAM,KAAMA,CAAAA,CAAAA;AAAA,QACZ,EAAEC,GAAO,KAAU,CAAA;AAAA;AACrB,KACF;AAAA,IACAC,CAAoB,EAAA;AAAA,MAClB,KAAO,EAAA,KAAA;AAAA,KACT;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,KAAO,EAAA,KAAA;AAAA;AACT,GACD,CAAA;AAAA,EACH,CAAC,KAAK;AACR,CAAA;AAEF,IAAO,yBAAQ,GAAA","file":"chunk-VEU3HCH6.cjs","sourcesContent":["import { useMemo } from 'react';\nimport type { LoadableState } from '../types';\nimport { createSubscribeWithError } from '../utils/createAsyncSubscribe';\n\n/**\n * A utility function to prevent hooks from triggering the loading behavior of a {@link state}.\n * Wrapping a {@link state} with this function ensures that hooks like `useValue` or `use`\n * will not initiate the loading, allowing you to access the current value without triggering a load.\n */\nconst useWithoutLoading = <S extends LoadableState>(\n  state: S\n): Omit<S, 'load'> =>\n  useMemo(\n    () =>\n      Object.create(state, {\n        _subscribeWithError: {\n          value: createSubscribeWithError(\n            state._root._callbacks,\n            state.error._callbacks,\n            { _load: undefined } as LoadableState\n          ),\n        },\n        _subscribeWithLoad: {\n          value: undefined,\n        },\n        load: {\n          value: undefined,\n        },\n      }),\n    [state]\n  );\n\nexport default useWithoutLoading;\n"]}