Permalink
Browse files

demo: Signal#sequence

  • Loading branch information...
1 parent 1b6c2ca commit 10b6435455acec0dfe8b77ba496b0aed4854c9d9 @nafg committed Sep 24, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 reactive-web-demo/src/main/webapp/core/Signal.html
View
11 reactive-web-demo/src/main/webapp/core/Signal.html
@@ -157,7 +157,7 @@
def nameAndAge(name: Signal[String], age: Signal[Int]): Signal[(String,Int)] = name zip age
</pre>
-<h3>Preventing infinite loops</h3>
+<h3>Preventing infinite loops: <code>distinct</code>, <code>nonrecursive</code></h3>
<p>When you have two interdependent signals, you need a way to prevent infinite loops
(signal A caused signal B to change which causes signal A to change). <code>Signal</code>
has two methods that return a new <code>Signal</code> identical to the parent <code>Signal</code>
@@ -168,6 +168,13 @@
<p>Another example is where rounding errors are not symmetric. For such scenarios, call <code>nonrecursive</code>, which
uses a <code>DynamicVariable</code> (Scala's <code>ThreadLocal</code>) to prevent recursion.</p>
-<h3>Time-consuming handling of values</h3>
+<h3>Time-consuming handling of values: <code>nonblocking</code>, <code>zipWithStaleness</code></h3>
<p>Similar to <code>EventStream</code>, <code>Signal</code> has <code>nonblocking</code> and <code>zipWithStaleness</code> methods.</p>
+
+<h3>Merging a variable number of signals: <code>sequence</code></h3>
+<p>How can you keep the total cost of several orders up to date? If you store it as a <code>Signal[Seq[Signal[Order]]]</code>, you can use <code>sequence</code>:</p>
+<pre class="brush:scala">
+orders.sequence.map(_.sum)
+</pre>
+
</div>

0 comments on commit 10b6435

Please sign in to comment.