How to resolve references for composed models #1674
-
In my application i would like to separate some UI specific views/actions from my business models. For example a have a 'Book' model. This model contains some attributes like: 'price', 'publish_date', and so on.
All these attributes are 'business specific'. I store such model instances in the model called 'DataStore', so i can get access to the business models just by reference from any places (for example from some page store). I would like to add some UI specific states/actions/views to such business model (but keep them separately, probably i will have another UI specific model in some other places) . For example i have a table component on the page, and i would like to pass 'data' prop inside it. There are cases when rows in table can change it's view depends on some business rules. For example if price of the book is bigger than 15$ we need to display some text inside tooltip, if bigger than 30$ than another text and so on. So idea is to create some 'ui specific' model:
In my app i have a page store:
I put fetched data in my DataStore, and ids in page store, and getting them by references. But because TableItem is another type mst can't resolve reference to the BookModel. I see that it's not how mst works, but probably there is a good similar way how i can reach it. Maybe i just missed something in the documentation :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @vvitto! Very interesting. The first thing that comes to mind for me is do you really want |
Beta Was this translation helpful? Give feedback.
Hi @vvitto!
Very interesting. The first thing that comes to mind for me is do you really want
types.reference(TableItem)
to resolve to aBookModel
instance? If it would work that way, you would not be able to reliably use views etc. fromTableItem
(e.g.tooltipText
in your example).