vuse-rx
Version:
First-class rxjs support for Vue 3
9 lines (7 loc) • 323 B
text/typescript
import { Unsubscribable } from 'rxjs';
import { onUnmounted } from 'vue';
/**
* Automatically unsubscribes from a subscription when onUnmounted hook executes
* @param subscrition - what to unsubscribe from
*/
export const useSubscription = (subscrition: Unsubscribable) => onUnmounted(() => subscrition.unsubscribe());