Skip to content

A pattern for sharing state between two stores #1933

Discussion options

You must be logged in to vote

Hi @davetapley!

Another approach to this problem could be to go by the common root of your stores and return rootStore.sensorStore.selected !== undefined as a view. This way you don't have to manually update this value.

Example (CodeSandbox)

const MenuStore = t.model("MenuStore").views((self) => ({
  get sensorSelected() {
    return getRoot<any>(self).sensorStore.selected !== undefined;
  }
}));

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@davetapley
Comment options

@EmilTholin
Comment options

@araphiel
Comment options

Answer selected by davetapley
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants