mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 16:13:12 +09:00
Remove channels to simplify subscription
Make subscriptions either on or off to greatly simplify the logic of subscribing to events.
This commit is contained in:
1 parent
a2eb98ac93
commit
58914042cc
11 files changed
+51
-279
No files matched your search
@@ -36,12 +36,15 @@ export function useHost(id: number): [ HostState, () => void ] {
|
||||
updateHost();
|
||||
|
||||
function updateHandler(newHost: lib.HostDetails) {
|
||||
if (newHost.id !== id) {
|
||||
return;
|
||||
}
|
||||
setHost({ ...newHost, loading: false, missing: false, present: true });
|
||||
}
|
||||
|
||||
control.hostUpdate.subscribeToChannel(id, updateHandler);
|
||||
control.hostUpdate.subscribe(updateHandler);
|
||||
return () => {
|
||||
control.hostUpdate.unsubscribeFromChannel(id, updateHandler);
|
||||
control.hostUpdate.unsubscribe(updateHandler);
|
||||
};
|
||||
}, [id]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user