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:
parent
09c3fc443b
commit
ca86bfc427
|
|
@ -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() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue