Last active
August 29, 2015 14:26
-
-
Save mattmccray/0c4aacd2b8eb4004788e to your computer and use it in GitHub Desktop.
mobservable minutia
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
| // 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