Restructure omni services and add Chatwoot research snapshot
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { ref, onBeforeUnmount } from 'vue';
|
||||
|
||||
export const useLiveRefresh = (callback, interval = 60000) => {
|
||||
const timeoutId = ref(null);
|
||||
|
||||
const startRefetching = () => {
|
||||
timeoutId.value = setTimeout(async () => {
|
||||
await callback();
|
||||
startRefetching();
|
||||
}, interval);
|
||||
};
|
||||
|
||||
const stopRefetching = () => {
|
||||
if (timeoutId.value) {
|
||||
clearTimeout(timeoutId.value);
|
||||
timeoutId.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopRefetching();
|
||||
});
|
||||
|
||||
return {
|
||||
startRefetching,
|
||||
stopRefetching,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user