ant-design-vue/components/_util/hooks/useBreakpoint.ts
John 0984951845
feat(v3/avatar): add avatar group (#4062)
* feat(avatar): add avatar group

* refactor: update

* refactor: update

Co-authored-by: tangjinzhou <415800467@qq.com>
2021-05-12 19:56:23 +08:00

22 lines
492 B
TypeScript

import { onMounted, onUnmounted, Ref, ref } from 'vue';
import ResponsiveObserve, { ScreenMap } from '../../_util/responsiveObserve';
function useBreakpoint(): Ref<ScreenMap> {
const screens = ref<ScreenMap>({});
let token = null;
onMounted(() => {
token = ResponsiveObserve.subscribe(supportScreens => {
screens.value = supportScreens;
});
});
onUnmounted(() => {
ResponsiveObserve.unsubscribe(token);
});
return screens;
}
export default useBreakpoint;