22 lines
559 B
JavaScript
22 lines
559 B
JavaScript
|
import { onActivated, onDeactivated } from 'vue';
|
||
|
export function useReactivated(callback) {
|
||
|
const isDeactivatedRef = {
|
||
|
isDeactivated: false
|
||
|
};
|
||
|
let activateStateInitialized = false;
|
||
|
onActivated(() => {
|
||
|
isDeactivatedRef.isDeactivated = false;
|
||
|
if (!activateStateInitialized) {
|
||
|
activateStateInitialized = true;
|
||
|
return;
|
||
|
}
|
||
|
callback();
|
||
|
});
|
||
|
onDeactivated(() => {
|
||
|
isDeactivatedRef.isDeactivated = true;
|
||
|
if (!activateStateInitialized) {
|
||
|
activateStateInitialized = true;
|
||
|
}
|
||
|
});
|
||
|
return isDeactivatedRef;
|
||
|
}
|