跳到主要内容

useSubscription

分类
导出大小
161 B
@vueuse/rxjs
上次更改
4 年前

使用 RxJS Subscription,无需担心取消订阅或造成内存泄漏。可在 @vueuse/rxjs 插件中使用。

用法

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)
    }),
)

类型声明

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

来源

源代码文档

贡献者

Anthony Fu
Anthony Fu
SerKo
Robin
Curt Grimes
katsuya_U
Michel Betancourt

更新日志

暂无最新更改

根据 MIT 许可证发布。