I just have a simple question that I couldn't find any answer by checking the documentation, as I mentioned in the issue title, is it okay to use single Observer widget for observable/computed from multiple store instances? or should I create another Observer widget for each store instance?
E.g:
Stores
part 'test_store_1.g.dart';
class TestStore1 = _TestStore1 with _$TestStore1;
abstract class _TestStore1 with Store {
@readonly
ObservableFuture<SomeViewData>? _someViewDataObservableFuture;
@computed
bool get isLoading => _someViewDataObservableFuture?.status == FutureStatus.pending;
@action
void getSomeViewData() {
_someViewDataObservableFuture = ObservableFuture(
_someUseCase.call(),
);
}
}
part 'test_store_2.g.dart';
class TestStore2 = _TestStore2 with _$TestStore2;
abstract class _TestStore2 with Store {
@readonly
ObservableFuture<SomeViewData2>? _someViewDataObservableFuture2;
@computed
bool get isLoading2 => _someViewDataObservableFuture2?.status == FutureStatus.pending;
@action
void getSomeViewData2() {
_someViewDataObservableFuture2 = ObservableFuture(
_someUseCase2.call(),
);
}
}
@memishood
It depends on your situation, but in the example described above, you can use only one. It is recommended to separate observers into widgets that need to be rebuilt, not by the number of observables.
I just have a simple question that I couldn't find any answer by checking the documentation, as I mentioned in the issue title, is it okay to use single Observer widget for observable/computed from multiple store instances? or should I create another Observer widget for each store instance?
E.g:
Stores
UI