constructor (props) { super(props) this.person = observable(personData) this.submitForm = this.submitForm.bind(this) }
constructor(props) { super(props); this.changeSelected = this.changeSelected.bind(this); this.store = observable({ lista: [ { id: 1, texto: 'UNO' }, { id: 2, texto: 'DOS' }, { id: 3, texto: 'TRES' }, { id: 4, texto: 'CUATRO' }, { id: 5, texto: 'CINCO' }, { id: 6, texto: 'SEIS' }, { id: 7, texto: 'SIETE' }, { id: 8, texto: 'OCHO' }, { id: 9, texto: 'NUEVE' }, { id: 10, texto: 'DIEGARDO' } ], itemSelected: 1 }); }
observable( { count: 0, incCount: () => appStore.count++, decCount: () => appStore.count--, get countByThree () { return appStore.count * 3 } }, { incCount: action, decCount: action, countByThree: computed })
observer( class RidiculousCounter extends Component { countState = observable({ count: 0 }); render() { return (
const messageServerice = messages => observable({ isFetching: false, addMessage(message) { this.isFetching = true; addMessageService(message) .then(() => { this.isFetching = false; }) .catch(() => { this.isFetching = false; }); } })
this.state = (0, _mobx.observable)({ user: user, error: null,
const messages = () => observable( { list: [ // message("pat", "this is test message", new Date(), false), // message("Private", "this is private test message", new Date(), true) ], addMessage(username, userMessage, createdAt, isPrivate) { this.list.push(message(username, userMessage, createdAt, isPrivate)); }, getList() { return this.list; } }, { addMessage: action } )
observable( { users: null, error: null, getUsers () { axios.get(`${process.env.REACT_APP_BACKEND_URL}/users`) .then(res => res.data) .then( users => { runInAction(() => { userStore.users = users }) }, error => { runInAction(() => { userStore.error = error }) } ) } }, { getUsers: action } )
constructor(props) { super(props); let user = observable({ username: '', password: '', }) this.handleChange = this.handleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); }
const message = (username, message, createdAt, isPrivate = false) => observable({ id: Math.random(), username, message, createdAt, isPrivate })