Last active
February 28, 2017 13:45
-
-
Save superplussed/5fb2d03018f2e51a87565f5a948f1d7f to your computer and use it in GitHub Desktop.
Troubleshooting a serialzr model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stores are like collections and hold routes | |
class SentenceStore extends RootStore { | |
constructor() { | |
super(); | |
this.config = { | |
model: Sentence, | |
deserialize: true, | |
GET: { | |
index: '/sentences', | |
show: '/sentences/:sentenceId', | |
}, | |
// in RootStore, I assign the results of the show request to this.current, deserializing against the Sentence model | |
this.current = deserialize(this.config.model, obj); | |
// my model holds the data and uses serializr, everything works great unless I add a constructor | |
class Sentence { | |
constructor() { // if I remove this everything works fine | |
this.sentenceState = new SentenceState(this); | |
} | |
@observable @serializable id; | |
@observable @serializable levelId; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment