Decorators in MobX
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
This comment has been minimized.
missing
action
in the import? thanks otherwise!