@aplus-frontend/antdv
Version:
Vue basic component library maintained based on ant-design-vue
20 lines • 413 B
JavaScript
import raf from '../../../_util/raf';
import { onBeforeUnmount, shallowRef } from 'vue';
/**
* Always trigger latest once when call multiple time
*/
export default () => {
const idRef = shallowRef(0);
const cleanUp = () => {
raf.cancel(idRef.value);
};
onBeforeUnmount(() => {
cleanUp();
});
return callback => {
cleanUp();
idRef.value = raf(() => {
callback();
});
};
};