Skip to content

Instantly share code, notes, and snippets.

@aqrojo
Last active April 8, 2021 09:42
Show Gist options
  • Save aqrojo/6121ac9ff195c3b10564e8c472f88a89 to your computer and use it in GitHub Desktop.
Save aqrojo/6121ac9ff195c3b10564e8c472f88a89 to your computer and use it in GitHub Desktop.
mobx-introduction_MST_1
import { types } from 'mobx-state-tree'
// definición de un modelo mobx-state-tree
const ThermometerModel = types
.model({
id: types.string,
celsius: types.number
})
.actions (state => ({
setCelsius (val) {
state.celsius = val
},
...
}))
.views (state => ({
get farenheight () {
return (state.celsius * (9/5)) + 32
},
...
}))
export default ThermometerModel
// instanciar un store
const thermomether = ThermometerModel.create({
id: 't1',
celsius: 33
})
@aqrojo
Copy link
Author

aqrojo commented Apr 7, 2021

Como crear un manager para este modelo:
https://gist.github.com/aqrojo/d2f7e6001137f0551e0b33d79a3dc7b2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment