From 60eda55ff1c5d68bb6b4d1ea49f22ccede87d22e Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 30 Dec 2008 16:08:25 -0500 Subject: Propagating a change through a bind --- jslib/urweb.js | 36 ++++++++++++++++++++++++++++++------ tests/reactive4.ur | 7 +++++++ tests/reactive4.urp | 3 +++ 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 tests/reactive4.ur create mode 100644 tests/reactive4.urp diff --git a/jslib/urweb.js b/jslib/urweb.js index 86c3808c..508f4318 100644 --- a/jslib/urweb.js +++ b/jslib/urweb.js @@ -1,18 +1,42 @@ +function cons(v, ls) { + return { n : ls, v : v }; +} function callAll(ls) { for (; ls; ls = ls.next) ls.v(); } -function sc(v) { return {v : v, h : null} } -function sv(s, v) { s.v = v; callAll(s.h); } +function sc(v) { + return {v : v, h : null}; +} +function sv(s, v) { + s.v = v; + callAll(s.h); +} -function ss(s) { return s } -function sr(v) { return {v : v, h : null} } -function sb(x,y) { return {v : y(x.v).v, h : null} } +function ss(s) { + return s; +} +function sr(v) { + return {v : v, h : null}; +} +function sb(x,y) { + var z = y(x.v); + var s = {v : z.v, h : null}; + + function reZ() { + z.h = cons(function() { s.v = z.v; callAll(s.h); }, z.h); + } + + x.h = cons(function() { z = y(x.v); reZ(); s.v = z.v; callAll(s.h); }, x.h); + reZ(); + + return s; +} function dyn(s) { var x = document.createElement("span"); x.innerHTML = s.v; document.body.appendChild(x); - s.h = { n : s.h, v : function() { x.innerHTML = s.v } }; + s.h = cons(function() { x.innerHTML = s.v }, s.h); } diff --git a/tests/reactive4.ur b/tests/reactive4.ur new file mode 100644 index 00000000..b5278a63 --- /dev/null +++ b/tests/reactive4.ur @@ -0,0 +1,7 @@ +fun main () : transaction page = + x <- source TEST; + return + !{y}?}/> +
+ CHANGEUP}>Oh My + diff --git a/tests/reactive4.urp b/tests/reactive4.urp new file mode 100644 index 00000000..e32cf7a7 --- /dev/null +++ b/tests/reactive4.urp @@ -0,0 +1,3 @@ +debug + +reactive4 -- cgit v1.2.3