generators inside DOM events

Andrea Giammarchi andrea.giammarchi at gmail.com
Wed Jan 8 13:21:28 PST 2014


sorry, actually the right example was with `while (true) yield evt;` but
that's the same of async callback, the event is gone.

Well, everything good then ^_^

Thanks again


On Wed, Jan 8, 2014 at 1:19 PM, Andrea Giammarchi <
andrea.giammarchi at gmail.com> wrote:

> OK, I have overlooked at this ... so the following code won't have any
> side effect, correct?
>
> ```javascript
> addEventListener('beforeunload', function (e) {
>   (function*() {
>     while (true) yield null;
>   }());
> });
> ```
>
> Thanks
>
>
> On Wed, Jan 8, 2014 at 1:12 PM, Brandon Benvie <bbenvie at mozilla.com>wrote:
>
>> On 1/8/2014 1:05 PM, Andrea Giammarchi wrote:
>>
>>> Sorry, I explained it badly ... let me try again:
>>>
>>> what if a DOM event handler uses/creates/invokes inside its function
>>> body a generator?
>>>
>>> Will the event pause until this will be satisfied?
>>>
>>> `a.addEventListener('click', function(e){ if(methodThatInvokesGenerator())
>>> e.stopPropagation(); });`
>>>
>>
>> Calling a generator function just creates a paused generator. Generators
>> can't pause callers, just themselves (via yield).
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140108/18946e31/attachment-0001.html>


More information about the es-discuss mailing list