Skip to content

Commit

Permalink
fix(useUserMedia): stop stream on scope dispose (vueuse#3757)
Browse files Browse the repository at this point in the history
  • Loading branch information
Waleed-KH authored and noook committed Mar 26, 2024
1 parent 5375c1e commit 79f04c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/useUserMedia/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* this implementation is original ported from https://github.com/logaretm/vue-use-web by Abdelrahman Awad */

import type { MaybeRef } from '@vueuse/shared'
import { type MaybeRef, tryOnScopeDispose } from '@vueuse/shared'
import type { Ref } from 'vue-demi'
import { ref, shallowRef, watch } from 'vue-demi'
import { useSupported } from '../useSupported'
Expand Down Expand Up @@ -109,6 +109,10 @@ export function useUserMedia(options: UseUserMediaOptions = {}) {
{ immediate: true },
)

tryOnScopeDispose(() => {
stop()
})

return {
isSupported,
stream,
Expand Down

0 comments on commit 79f04c3

Please sign in to comment.