Mobx computed example
Shows mobx's computed value feature and how it caches it's value
author(s):
Matt Ruby
HTML
<div id="react-log"></div>
<script src="https://cdn.jsdelivr.net/g/[email protected](react.min.js+react-dom.min.js),[email protected]"></script>
<script src="https://npmcdn.com/[email protected]/lib/mobx.umd.min.js"></script>
<script src="https://npmcdn.com/mobx-react"></script>
<script src="https://rawgit.com/mattruby/mobx-examples/master/logging-utils.js"></script>
<!--<script src="../logging-utils.js"></script>-->
<script>
wrapConsole();
</script>
<!--<script src="demo.js"></script>-->
JavaScript
var person = mobx.observable({
firstName: 'fdsf',
lastName: 'Ruby',
age: 0,
fullName: function () {
return this.firstName + ' ' + this.lastName;
}
});
console.log(person.fullName);
person.firstName = 'bsdasdsa';
console.log(person.fullName);
person.firstName = 'Lissy';
console.log(person.fullName);
setTimeout(()=>{
person.firstName ='bhavesh'
},5000)