W3C home > Mailing lists > Public > public-xformsusers@w3.org > May 2017

Re: Dispatch with delay="0"

From: Steven Pemberton <steven.pemberton@cwi.nl>
Date: Tue, 30 May 2017 15:37:36 +0200
To: "public-xformsusers@w3.org" <public-xformsusers@w3.org>, "Erik Bruchez" <erik@bruchez.org>
Message-ID: <op.y01z4yz0smjzpq@steven-xps>
A question about the interaction between dispatch/@delay and model-update.

A model update is only done after any outermost action handler is finished.
https://www.w3.org/community/xformsusers/wiki/XForms_2.0#Updates

So, does a dispatch with no delay leave the current handler running?
Does a dispatch with delay="0" mean that the current handler finishes  
before the dispatched event gets dispatched?

In other words, with the following, does k end up with 2 or 1000? And does  
it make a difference if I delete the 'delay="0"'?

<model id="m">
    <instance>
       <data xmlns="">
          <i>1</i>
          <j>2</j>
          <k>0</k>
       </data>
    </instance>
    <bind ref="j" calculate="../i+1"/>

    <action ev:event="xforms-ready">
       <setvalue ref="i" value="999"/>
       <dispatch event="go" delay="0" targetid="m"/>
    </action>

    <action ev:event="go">
       <setvalue ref="k" value="j"/>
    </action>
</model>

Steven

On Wed, 24 May 2017 00:21:54 +0200, Erik Bruchez <erik@bruchez.org> wrote:

> All,
>
>> The spec says:
>
>> "If the delay is zero, or does not conform to xs:nonNegativeInteger,  
>> then the event is dispatched immediately"
>
>> I assume that it means dispatched synchronously. This means that there  
>> is a difference of synchronicity >between:
>
>>    <xf:dispatch name="foo" targetid="my-model" delay="0"/>
>
>> and:
>
>>    <xf:dispatch name="foo" targetid="my-model" delay="1"/>
>
>> It would be nice to be able to add an event to the event queue  
>> immediately. Using `delay="1"` is close but not >ideal.
>
>> The obvious way of doing that would be to change the spec and say that  
>> if `delay` is present and contains a >number, the event is always added  
>> to the queue. So you always get asynchronous dispatch with a numeric  
>> >`delay`.
>
>> Now, this causes a problem if you want to have a single action which,  
>> via an AVT, allows for both asynchronous >dispatch and asynchronous  
>> dispatch. A special value, such as `delay="none"` could possibly be  
>> used.
>
>>    <xf:dispatch name="foo" targetid="my-model" delay="none"/>
>
>> Or an empty value:
>
>>    <xf:dispatch name="foo" targetid="my-model" delay=""/>
>
>> Also, a case could be made that if `delay` evaluates to something which  
>> is not a number and not a value >indicating synchronous dispatch, then  
>> the event dispatch shouldn't take place (or an error could be raised):
>
>>    <xf:dispatch name="foo" targetid="my-model" delay="bar"/>
>
>> Thoughts?
>
>> -Erik
Received on Tuesday, 30 May 2017 13:38:14 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 30 May 2017 13:38:15 UTC