refactor: use effect for assignSelector in BaseGameClient

Replace subscribe with effect in assignSelector to ensure the
selector value is tracked and the callback is executed within
the reactive context.
This commit is contained in:
2026-04-28 15:50:00 +08:00
parent 09c3fc443b
commit ca86bfc427
+3 -1
View File
@@ -60,7 +60,9 @@ export abstract class BaseGameClient<
assignSelector<S>(selector: (t: T) => S, callback: (s: S) => void) { assignSelector<S>(selector: (t: T) => S, callback: (s: S) => void) {
const selected = computed(() => selector(this._context.value)); const selected = computed(() => selector(this._context.value));
return selected.subscribe(callback); return effect(() => {
callback(selected.value);
});
} }
addInterruption() { addInterruption() {