Skip to content

Instantly share code, notes, and snippets.

@superplussed
Last active February 28, 2017 13:45
Show Gist options
  • Save superplussed/5fb2d03018f2e51a87565f5a948f1d7f to your computer and use it in GitHub Desktop.
Save superplussed/5fb2d03018f2e51a87565f5a948f1d7f to your computer and use it in GitHub Desktop.
Troubleshooting a serialzr model
// 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