Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useSubscription.md
1---2category: '@RxJS'3---45# useSubscription67Use an RxJS [`Subscription`](https://rxjs.dev/guide/subscription) without worrying about unsubscribing from it or creating memory leaks.89## Usage1011<!-- TODO: import rxjs error if enable twoslash -->1213```ts no-twoslash14import { useSubscription } from '@vueuse/rxjs'15import { interval } from 'rxjs'1617const count = ref(0)1819// useSubscription call unsubscribe method before unmount the component20useSubscription(21interval(1000)22.subscribe(() => {23count.value++24console.log(count)25}),26)27```2829## Type Declarations3031```ts32export declare function useSubscription(subscription: Unsubscribable): void33```34