Files
zyt/wx/TUICallKit/src/Components/hooks/useNetWorkStatus.ts
T
2026-03-04 15:32:30 +08:00

31 lines
774 B
TypeScript

import { ref, onMounted, onUnmounted } from '../../adapter-vue';
import { TUIStore } from '../../TUICallService';
import { NAME, StoreName } from '../../TUICallService/const';
export function useNetWorkStatus() {
const netWorkQualityList = ref(TUIStore.getData(StoreName.CALL, NAME.NETWORK_STATUS));
const handleNetWorkStatusChange = (value) => {
netWorkQualityList.value = value;
};
onMounted(() => {
TUIStore.watch(
StoreName.CALL,
{
[NAME.NETWORK_STATUS]: handleNetWorkStatusChange,
},
{
notifyRangeWhenWatch: NAME.MYSELF,
},
);
});
onUnmounted(() => {
TUIStore.unwatch(StoreName.CALL, {
[NAME.NETWORK_STATUS]: handleNetWorkStatusChange,
});
});
return { netWorkQualityList };
}