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:
hypercross 2026-04-28 15:50:00 +08:00
parent 09c3fc443b
commit ca86bfc427
1 changed files with 3 additions and 1 deletions

View File

@ -60,7 +60,9 @@ export abstract class BaseGameClient<
assignSelector<S>(selector: (t: T) => S, callback: (s: S) => void) {
const selected = computed(() => selector(this._context.value));
return selected.subscribe(callback);
return effect(() => {
callback(selected.value);
});
}
addInterruption() {