Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Call setState inside StoreWatcher #30

Closed
trinhtuanvu opened this issue May 16, 2018 · 2 comments
Closed

Call setState inside StoreWatcher #30

trinhtuanvu opened this issue May 16, 2018 · 2 comments

Comments

@trinhtuanvu
Copy link

Using StoreWatcher, how can I call setState() inside my custom handler?

class MyWidget extends StoreWatcher {
  @override
  void initStores(ListenToStore listenToStore) {
    listenToStore(storeToken, customHandleStoreChanged);
  }
  void customHandleStoreChanged(Store store) {
    // ...
    // setState(() {});
  }
}
@jimbeveridge
Copy link
Contributor

I suggest you switch to StoreWatcherMixin as shown in the latest example. This should be a fairly straightforward change. StoreWatcherMixin is added to your State class and so will make calling setState() trivial.

The StoreWatcher class was intended to be a quick way to get started with flutter_flux, but it didn't work out as well as I'd hoped.

@trinhtuanvu
Copy link
Author

Thanks for the answer. So the custom handler is not very useful and seems never be used.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants