13. JavaScript での実装例
?-?イベント駆動
function onChange() {
var a = Number($("#val1").val());
var b = Number($("#val2").val());
var c = a + b;
$("#val3").text(c);
}
$("#val1").change(onChange);
$("#val2").change(onChange);
23. +
配線をつくる
a
b
c
function Model() {
var me = this;
me.a = new Bacon.Bus();
me.b = new Bacon.Bus();
me.c = new Bacon.Bus();
Bacon.combineWith(function(a, b) { return a + b; }, me.a, me.b)
}
24. 配線をつくる
+
a
b
c
function Model() {
var me = this;
me.a = new Bacon.Bus();
me.b = new Bacon.Bus();
me.c = new Bacon.Bus();
Bacon.combineWith(function(a, b) { return a + b; }, me.a, me.b).change()
}
25. 配線をつくる
+
a
b
c
function Model() {
var me = this;
me.a = new Bacon.Bus();
me.b = new Bacon.Bus();
me.c = new Bacon.Bus();
me.c.plug(
Bacon.combineWith(function(a, b) { return a + b; }, me.a, me.b).change()
);
}