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

Re: Dispatch with delay="0"

From: Erik Bruchez <erik@bruchez.org>
Date: Tue, 30 May 2017 22:21:32 -0700
Message-ID: <CAAc0PEVM9k14ise0tin0pUajA+ZJouQaoGpiN0N-zB-wUzaw7Q@mail.gmail.com>
To: Steven Pemberton <steven.pemberton@cwi.nl>
Cc: "public-xformsusers@w3.org" <public-xformsusers@w3.org>
This is related to my question about whether event dispatch without a
`delay` attribute or a `delay="0"` attribute is synchronous or asynchronous.

In my interpretation:

- no `delay` attribute means synchronous dispatch
- there is no model update specified for synchronous events
- `delay="0"`should probably be asynchronous

With `<dispatch event="go" targetid="m"/>`, the dispatch is syncrhonous and
the result would be 2.

With `<dispatch event="go" delay="0" targetid="m"/>`, the dispatch is
asynchronous and so takes place after the model update and refresh which
happens after `xforms-ready`, so the result would be 1000.

-Erik


On Tue, May 30, 2017 at 6:37 AM, Steven Pemberton <steven.pemberton@cwi.nl>
wrote:

> 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 Wednesday, 31 May 2017 05:22:26 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:37:48 UTC