Flutterando / triple_pattern

Segmented State Pattern for Reactive Property
MIT License
160 stars 36 forks source link

How to use multiple store #96

Closed cyclothunder closed 2 years ago

cyclothunder commented 2 years ago

Hi, How can I use multiple store on a view?

For example:

final counter = CounterStore();
final otherCounter = OtherCounter();

Reading through documentation in Observers and Builders, those examples use only one store, like the ScopedBuilder for instance.

ScopedBuilder(
    store: counter,
    onState: (context, state) => Text('$state'),
    onError: (context, error) => Text(error.toString()),
    onLoading: (context) => CircularProgressIndicator(),
);
tauamendonca commented 2 years ago

For now there's no such option natively in Triple (and thank you for pointing out, we are looking and discussing about it's implementation).

It's not advised, because it can lead to some issues, but you could use a ScopedBuilder inside another ScopedBuilder and it can work.