Skip to content

Derived values from other store #1918

Discussion options

You must be logged in to vote

Hi @juanmavillarrazadb!

Values returned from an action will not be observed. You could instead have the AssetsStore action getById be returned from a views block and it will be observed:

export const AssetsStore = types
  .model("AssetsStore", {
    assets: types.array(Asset),
    fetching: false
  })
  .views((self) => ({
    getById(id: string): IAsset | undefined {
      return self.assets.find((i) => i.id === id);
    }
  }))
  // ...

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@EmilTholin
Comment options

@juanmavillarrazadb
Comment options

Answer selected by EmilTholin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants