Skip to content

Instantly share code, notes, and snippets.

@mweststrate

mweststrate/decorators.js

Last active Mar 12, 2018
Embed
What would you like to do?
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
})
@themre

This comment has been minimized.

Copy link

@themre themre commented Mar 12, 2018

missing action in the import? thanks otherwise!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.