Closed justin-hackin closed 2 years ago
After reading the following from DataModel docs "Data models, like class models, define the behaviors (actions/views) that can be performed over data, but without tainting the data itself with $modelType / $modelId", I'm not sure if the DataModel lacks a $modelName
property or if it's just the snaphot that is not "tainted" with it. It would be unfortunate if I had to change a DataModel to a Model just in order to access $modelName
For an MST model, I was able to get a static property name as the first parameter supplied to types.model. I believe I can access the arg of @model decorator with instance.$modelType
Right now you can do that if it is a class model, yes
If it is a DataModel you cannot do that (data models are thin wrappers over an object), but you could always do
const MyModelTypeName = 'whatever'
@model(MyModelTypeName)
class MyModelType ... {}
....
is there any specific reason why you need to access the model type of a data model?
Closing due to inactivity
For an MST model, I was able to get a static property
name
as the first parameter supplied totypes.model
. I believe I can access the arg of@model
decorator withinstance.$modelType
. If this is correct, I think adding a note to https://mobx-keystone.js.org/public/api/index.html#modelname
property would be helpful. "Unique name for the model type." could be "Unique name for the model type, accessible on the model instance as $modelType property". If that is suiting, I'd be happy to make a PR along with some other docs typos I found.