Skip to content

Instantly share code, notes, and snippets.

@mattmccray
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save mattmccray/0c4aacd2b8eb4004788e to your computer and use it in GitHub Desktop.

Select an option

Save mattmccray/0c4aacd2b8eb4004788e to your computer and use it in GitHub Desktop.
mobservable minutia
// So these are essentially equivalent in the latest/upcoming mobservable release, yeah? (Not count differences from Babel)
class FormField {
constructor() {
makeReactiveProps( this, {
pristine: "",
validators: [],
value: "",
isDirty() {
return this.value != this.pristine
},
isValid() {
return this.validators.every( validate => validate( this ) )
}
})
}
}
// And
class FormField {
@observable pristine = ""
@observable validators = []
@observable value = ""
@observable
isDirty() {
return this.value != this.pristine
}
@observable
isValid() {
return this.validators.every( validate => validate( this ) )
}
}
// Correction, it'd be more like this:
class FormField {
@observable pristine = ""
@observable validators = []
@observable value = ""
@observable
get isDirty() {
return this.value != this.pristine
}
@observable
get isValid() {
return this.validators.every( validate => validate( this ) )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment