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

how to listen to similar stores with different arguments #39

Open
lzh77 opened this issue Oct 9, 2018 · 1 comment
Open

how to listen to similar stores with different arguments #39

lzh77 opened this issue Oct 9, 2018 · 1 comment

Comments

@lzh77
Copy link

lzh77 commented Oct 9, 2018

There are some tab pages like fragment on android, I use constructor arguments to conotrol their stores. Like this:

List<GankPage> pages = [
  TabPage('aaa'),
  TabPage('bbb'),
]

class TabPage extends StoreWatcher {
  String type;
  StoreToken pageStoreToken;
  TabPage({Key k, this.type}) : super(key: k);

  @override
  void initStores(ListenToStore listenToStore) {
    pageStoreToken = StoreToken(PageStore(this.type));
    listenToStore(pageStoreToken);
    pageAction.call();
  }

}

If I write like this, when I switch tab the old actions will be called.
I saw the note is that stores should not depend on any constructor parameters.
Any suggetions?

@iptton
Copy link

iptton commented Mar 7, 2019

maybe storeToken should be global object but not instanced at method initStores ?

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