ant-design-vue/components/_util/hooks/_vueuse/useSupported.ts

14 lines
332 B
TypeScript
Raw Normal View History

2022-11-07 05:42:51 +00:00
import { tryOnMounted } from './tryOnMounted';
2023-04-05 14:03:02 +00:00
import { shallowRef } from 'vue';
2022-11-07 05:42:51 +00:00
export function useSupported(callback: () => unknown, sync = false) {
2023-04-05 14:03:02 +00:00
const isSupported = shallowRef<boolean>();
2022-11-07 05:42:51 +00:00
const update = () => (isSupported.value = Boolean(callback()));
update();
tryOnMounted(update, sync);
return isSupported;
}