Last active
March 12, 2018 19:46
-
-
Save mweststrate/6daf9eee8a10d8929937c0237890bca1 to your computer and use it in GitHub Desktop.
Decorators in MobX
This file contains 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
import { decorate, observable, flow } from "mobx" | |
/** | |
with decorator syntax enabled | |
*/ | |
class City { | |
@observable location | |
@observable temperature | |
@action.bound | |
fetchTemperature () { | |
/* implementation */ | |
} | |
} | |
/** | |
without decorator syntax enabled | |
*/ | |
class City { | |
location | |
temperature | |
fetchTemperature () { | |
/* implementation */ | |
} | |
} | |
decorate(City, { | |
location: observable, | |
temperature: observable, | |
fetchTemperature: action.bound | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
missing
action
in the import? thanks otherwise!