Arjun Guha wrote:
>
>> Does this same concept carry over to merged events? That is, will an
>> event stream built from the merge of several others refrain from
>> firing an event until all of its parents that are downstream from the
>> initial event fire?
>>
>
> This is not correct. A merged event stream will fire when any of its
> children fire. For an example of why this matters, look at the paper
> (section 2.3). The example uses mergeE in two different places. In
> particular:
>
> mkSaveBox(timerE(60000))
>
> fires when timerE fires.
>
> mkSaveBox($E(btn, "click"))
>
> fires when btn is clicked
>
> mkSaveBox(mergeE(timerE(60000), $E(btn, "click")))
>
> fires immediately when either timerE fires or btn is clicked.
>
Right. I don't think I phrased my question correctly - let me try to
clarify:
Will a merged stream refrain from firing *within a single time step*
until all of its parents *that will fire in that same time step* fire?
For example,
var a = oneE(null);
var b = mergeE(a, timerE(1000));
var c = mergeE(a, b);
When /a/ fires, /b/ and /c/ should both fire, but when /b/ fires, /c/
should also fire. Therefore, when /a/ fires once, does this cause /c/
to fire exactly once (after /b/ fires), or exactly twice (before and
after /b/ fires), or is there no guarantee either way?
Thank you,
John
In that case, I think the "DOM Manipulation" functions that act on
behaviors and event streams (insertValueB/E, insertDomB/E, etc.) should
return corresponding behaviors and event streams that could be used to
place operations /semantically after/ the DOM has been manipulated.
Currently, such an ordering can be produced by placing those operations
/lexically after/ the manipulations, but this is not fundamentally
reliable behavior (nor would I expect it to be).
For example,
1. var id = ... ;
2. var form_htmlB = ... ;
3. var formB = insertValueB(form_htmlB, "the_form", "innerHTML");
4. var nameB = formB.liftB(function () { return $B(id); }).switchB();
In this example, formB is a behavior holding a string of HTML that
declares a form. The form's number and types of children elements may
change over time.
After the form is inserted into the DOM, we want to create a new value
listener for the element with a given id.
Here is how the above must be written currently:
1. var formB = form_htmlB
2. .liftB(function (form_html) { $("the_form).innerHTML =
form_html; })
3. var nameB = formB
4. .liftB(function () { return $B(id); })
5. .switchB();
Note that these five lines perform exactly the same operations as lines
3 and 4 in the previous example, except that I had to re-implement
insertValueB() on line 2 here.
I'm also concerned that manipulating the DOM may be asynchronous. I am
not too familiar with the current state of the art of web development,
so does anyone know if it is? If so, then how will the application know
when an element is available for listening, especially in the case where
the element is inserted using innerHTML? I looked briefly, but I am not
aware of any tool for parsing an HTML string into DOM elements.
Thanks,
John
Will an event stream that takes a snapshot of a behavior wait until that
behavior has updated during the current time step before taking the
snapshot, or is there no guarantee either way?
Thanks,
John