Skip to content

useSubscription

使用 RxJS Subscription 无需担心取消订阅或造成内存泄漏。

¥Use an RxJS Subscription without worrying about unsubscribing from it or creating memory leaks. Available in the @vueuse/rxjs add-on.

用法

¥Usage

ts
import { useSubscription } from '@vueuse/rxjs'
import { interval } from 'rxjs'

const count = ref(0)

// useSubscription call unsubscribe method before unmount the component
useSubscription(
  interval(1000)
    .subscribe(() => {
      count.value++
      console.log(count)
    }),
)

类型声明

typescript
export declare function useSubscription(subscription: Unsubscribable): void

源代码

源代码文档

变更日志

No recent changes

VueUse 中文网 - 粤ICP备13048890号