UNPKG

@aplus-frontend/antdv

Version:

Vue basic component library maintained based on ant-design-vue

20 lines 413 B
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(); }); }; };