Skip to content

Instantly share code, notes, and snippets.

@adityavm
Last active January 10, 2016 09:03
Show Gist options
  • Save adityavm/3b27668198a9a5ede9fc to your computer and use it in GitHub Desktop.
Save adityavm/3b27668198a9a5ede9fc to your computer and use it in GitHub Desktop.
function Model(msg){
this.message = msg;
}
r.Inheritor(Model, r.Observer);
let mp = Model.prototype;
mp.change = function(msg) {
this.message = msg;
this.emit("valchange");
}
mp.model = function() {
let that = this;
return {
message: that.message
}
}
let model = new Model("Hello!"),
helloworld = new Vue({
el: "#app",
data: model.model()
});
let dynModel = new Model("(dyn) Hello!"),
dynhelloworld = new Vue({
el: "#app2",
data: dynModel.model()
});
dynModel.on("valchange", () => {
dynhelloworld.message = dynModel.model().message;
})
setTimeout(() => {
dynModel.change("World!");
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment