mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +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
@@ -79,12 +79,15 @@ export function useUser(name: string): [RawUserState, () => void] {
|
||||
updateUser();
|
||||
|
||||
function updateHandler(newUser: lib.User) {
|
||||
if (newUser.name !== name) {
|
||||
return;
|
||||
}
|
||||
setUser({ ...newUser, present: true });
|
||||
}
|
||||
|
||||
control.userUpdate.subscribeToChannel(name, updateHandler);
|
||||
control.userUpdate.subscribe(updateHandler);
|
||||
return () => {
|
||||
control.userUpdate.unsubscribeFromChannel(name, updateHandler);
|
||||
control.userUpdate.unsubscribe(updateHandler);
|
||||
};
|
||||
}, [name]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user