koel/resources/assets/js/composables/useScreen.ts

17 lines
444 B
TypeScript
Raw Normal View History

import { ref, watch } from 'vue'
import { requireInjection } from '@/utils'
import { ActiveScreenKey } from '@/symbols'
export const useScreen = (currentScreen: ScreenName) => {
const activeScreen = requireInjection(ActiveScreenKey, ref('Home'))
const onScreenActivated = (cb: Closure) => watch(activeScreen, screen => screen === currentScreen && cb(), {
immediate: true
})
return {
activeScreen,
onScreenActivated
}
}