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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user