mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 13:39:40 +08:00
16 lines
334 B
TypeScript
16 lines
334 B
TypeScript
import { getCurrentScope, onScopeDispose } from 'vue';
|
|
import type { Fn } from './types';
|
|
|
|
/**
|
|
* Call onScopeDispose() if it's inside a effect scope lifecycle, if not, do nothing
|
|
*
|
|
* @param fn
|
|
*/
|
|
export function tryOnScopeDispose(fn: Fn) {
|
|
if (getCurrentScope()) {
|
|
onScopeDispose(fn);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|