Last active
July 13, 2016 05:53
-
-
Save joynal/fd55e1284504187774514e898b0990c1 to your computer and use it in GitHub Desktop.
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
class Person{ | |
@observable firstName = 'David'; | |
@observable lastName = 'Khan'; | |
@observable age = 23; | |
@computed fullName(){ | |
return firstName + ' ' + lastName; | |
} | |
@action changeName(firstName, lastName){ | |
this.firstName = firstName; | |
this.lastName = firstName; | |
} | |
} | |
mobx.autorun(() => { | |
console.log(obj.fullName); | |
}); | |
let obj = new Person(); | |
obj.changeName('Suzon', 'Zahid'); | |
// David khan | |
// Suzon Zahid | |
import React, {Component} from 'react'; | |
import {render} from 'react-dom'; | |
@observer | |
class PersonView extends Component{ | |
render(){ | |
setTimeout(this.props.person.changeName('Joynal', 'Abedin'), 5000); | |
return ( | |
<h1>{this.props.person.firstName} {this.props.person.lastName}<h1> | |
); | |
} | |
} | |
render( | |
<PersonView person={new Person}/>, | |
document.getElementById('app'); | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment