Skip to content

useSubscription ​

类别
导出体积
162 B
依赖包
@vueuse/rxjs
上次更改
5 years ago

使用 RxJS Subscription,无需担心取消订阅或创建内存泄漏。 Available in the @vueuse/rxjs add-on.

用法 ​

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

const count = ref(0)

// 在组件卸载前调用 unsubscribe 方法
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

更新日志 ​

没有最近的更新日志