Refactor to use subsribers

This commit is contained in:
Cooldude2606 committed 2023-09-05 01:46:45 +01:00
1 parent 17943c48c3
commit da25196830
16 files changed
+120 -707

No files matched your search

+4 -4
View File
@@ -38,9 +38,9 @@ export function useHost(id: number): [ HostState, () => void ] {
setHost({ ...newHost, loading:false, missing:false, present:true });
}
control.onHostUpdate(id, updateHandler);
control.hostUpdate.subscribeToChannel(id, updateHandler);
return () => {
control.offHostUpdate(id, updateHandler);
control.hostUpdate.unsubscribeFromChannel(id, updateHandler);
};
}, [id]);
@@ -74,9 +74,9 @@ export function useHostList() {
});
}
control.onHostUpdate(null, updateHandler);
control.hostUpdate.subscribe(updateHandler);
return () => {
control.offHostUpdate(null, updateHandler);
control.hostUpdate.unsubscribe(updateHandler);
};
}, []);