mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33: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
@@ -32,12 +32,15 @@ export function useInstance(id: number): [InstanceState, ()=>void] {
|
||||
updateInstance();
|
||||
|
||||
function updateHandler(newInstance: lib.InstanceDetails) {
|
||||
if (newInstance.id !== id) {
|
||||
return;
|
||||
}
|
||||
setInstance({ ...newInstance, present: true });
|
||||
}
|
||||
|
||||
control.instanceUpdate.subscribeToChannel(id, updateHandler);
|
||||
control.instanceUpdate.subscribe(updateHandler);
|
||||
return () => {
|
||||
control.instanceUpdate.unsubscribeFromChannel(id, updateHandler);
|
||||
control.instanceUpdate.unsubscribe(updateHandler);
|
||||
};
|
||||
}, [id]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user