Derived values from other store #1918
-
Hi everyone, we have the following issue in our project, what we are trying to achieve is to use the derived values or views consuming the information from an other store, as we have the store design and definition based on the business logic. So we have the following files: ROOT STORE
ASSET STORE
USER STORE (this is the one with the view)
THE UI (that renders the computed value or view)
No matter how many time I click on the load button that replace the array value with mocked data I always get the same output on the render "No Data". We try also to import directly the Seems to me that something with the observable is broken maybe, or there's something I'm missing. A hack that I found out is the following:
Calling any method of the store data seems to wake up the observable or |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Values returned from an 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);
}
}))
// ... |
Beta Was this translation helpful? Give feedback.
Hi @juanmavillarrazadb!
Values returned from an
action
will not be observed. You could instead have theAssetsStore
actiongetById
be returned from aviews
block and it will be observed: