Last active
July 16, 2016 14:49
-
-
Save mweststrate/a890bbac9767c13fd85b to your computer and use it in GitHub Desktop.
Object.observe is dead. Long live Mobservable.observe
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
// JSBin: http://jsbin.com/kekoli/edit?js,console | |
import {observable, observe} from "mobx"; | |
const person = observable({ | |
firstName: "Maarten", | |
lastName: "Luther" | |
}); | |
const disposer = observe(person, (change) => { | |
console.log(`${change.type} '${change.name}' from '${change.oldValue}' to '${change.object[change.name]}'`); | |
}); | |
person.firstName = "Martin"; | |
// Prints: 'update 'firstName' from 'Maarten' to 'Martin' | |
disposer(); | |
// Ignore any future updates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment