Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retreiving the modelType by class #90

Closed
martinheidegger opened this issue Jan 11, 2020 · 2 comments · Fixed by #99
Closed

Retreiving the modelType by class #90

martinheidegger opened this issue Jan 11, 2020 · 2 comments · Fixed by #99
Labels
🍗 enhancement New feature or request 👨‍💻 has PR A PR that potentially fixes the issue exists

Comments

@martinheidegger
Copy link

To avoid mistakes and provide better logging it would be nice if the class instance of Models would have a $modelType property and print the output beautifully:

@model('com/myModel')
class MyModel extends Model({
 name: prop(() => 'hello')
}) {
  x: number // not-stored-properties not rendered
}

console.log(MyModel.$modelType) // com/myModel
console.log(MyModel)
// [constructor MyModel#com/myModel]

const inst = new MyModel({})
console.log(inst)
// [MyModel#com/myModel$modelId { name: "hello" }]
@xaviergonz xaviergonz added the 🍗 enhancement New feature or request label Jan 11, 2020
@xaviergonz
Copy link
Owner

Sounds good!

@xaviergonz xaviergonz added the 👨‍💻 has PR A PR that potentially fixes the issue exists label Jan 12, 2020
@xaviergonz
Copy link
Owner

xaviergonz commented Jan 12, 2020

PR open. In this case I didn't add $modelId to the logging of the instance since it is already present in the snapshot
e.g.

console.log(inst)
// [MyModel#com/myModel { name: "hello",$modelId:"id1",$modelType:"com/myModel" }]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍗 enhancement New feature or request 👨‍💻 has PR A PR that potentially fixes the issue exists
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants