Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
package.lib.composables.toggleScope.mjs.map Maven / Gradle / Ivy
{"version":3,"file":"toggleScope.mjs","names":["effectScope","onScopeDispose","watch","useToggleScope","source","fn","scope","start","run","length","stop","active","undefined","immediate"],"sources":["../../src/composables/toggleScope.ts"],"sourcesContent":["// Utilities\nimport { effectScope, onScopeDispose, watch } from 'vue'\n\n// Types\nimport type { EffectScope, WatchSource } from 'vue'\n\nexport function useToggleScope (source: WatchSource, fn: (reset: () => void) => void) {\n let scope: EffectScope | undefined\n function start () {\n scope = effectScope()\n scope.run(() => fn.length\n ? fn(() => { scope?.stop(); start() })\n : (fn as any)()\n )\n }\n\n watch(source, active => {\n if (active && !scope) {\n start()\n } else if (!active) {\n scope?.stop()\n scope = undefined\n }\n }, { immediate: true })\n\n onScopeDispose(() => {\n scope?.stop()\n })\n}\n"],"mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,cAAc,EAAEC,KAAK,QAAQ,KAAK;;AAExD;;AAGA,OAAO,SAASC,cAAcA,CAAEC,MAA4B,EAAEC,EAA+B,EAAE;EAC7F,IAAIC,KAA8B;EAClC,SAASC,KAAKA,CAAA,EAAI;IAChBD,KAAK,GAAGN,WAAW,CAAC,CAAC;IACrBM,KAAK,CAACE,GAAG,CAAC,MAAMH,EAAE,CAACI,MAAM,GACrBJ,EAAE,CAAC,MAAM;MAAEC,KAAK,EAAEI,IAAI,CAAC,CAAC;MAAEH,KAAK,CAAC,CAAC;IAAC,CAAC,CAAC,GACnCF,EAAE,CAAS,CAChB,CAAC;EACH;EAEAH,KAAK,CAACE,MAAM,EAAEO,MAAM,IAAI;IACtB,IAAIA,MAAM,IAAI,CAACL,KAAK,EAAE;MACpBC,KAAK,CAAC,CAAC;IACT,CAAC,MAAM,IAAI,CAACI,MAAM,EAAE;MAClBL,KAAK,EAAEI,IAAI,CAAC,CAAC;MACbJ,KAAK,GAAGM,SAAS;IACnB;EACF,CAAC,EAAE;IAAEC,SAAS,EAAE;EAAK,CAAC,CAAC;EAEvBZ,cAAc,CAAC,MAAM;IACnBK,KAAK,EAAEI,IAAI,CAAC,CAAC;EACf,CAAC,CAAC;AACJ","ignoreList":[]}