Skip to content

Commit

Permalink
fix(useScript,vue): abort load trigger on scope dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Oct 14, 2024
1 parent 4416366 commit e776256
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vue/src/composables/useScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ function registerVueScopeHandlers<T extends Record<symbol | string, any> = Recor
// if we have a scope we should make these callbacks reactive
script.onLoaded = (cb: (instance: T) => void | Promise<void>) => _registerCb('loaded', cb)
script.onError = (cb: (err?: Error) => void | Promise<void>) => _registerCb('error', cb)
onScopeDispose(() => {
// stop any trigger promises
script._triggerAbortController?.abort()
})
}

export function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>, U = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T, U>): UseScriptContext<UseFunctionType<UseScriptOptions<T, U>, T>> {
Expand Down

0 comments on commit e776256

Please sign in to comment.