You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Michael Gatto <mg...@vinsuite.com> on 2018/10/03 14:46:36 UTC
iOS and fireDocumentEvent
Hello All,
I’m trying to better understand a few things regarding Cordova iOS’s JS events.
* Why do we need setTimeout with some events?
* Are there any advantages to using fireDocumentEvent compared to fireWindowEvent?
Thanks,
--
Michael Gatto
Re: iOS and fireDocumentEvent
Posted by Jesse <pu...@gmail.com>.
setTimeout is for async interfaces that really aren't, and ensuring a clear
stack frame before calling the callback. Having the success callback
called before the developer has handed control to the library could break
the developer's code.
ex.
let num; // undefined
let cbSuccess = function() {
// code here expects some value of num
}
cordova.exec(cbSuccess, .... ) // implicit async call to cbSuccess
// some code here that is expected to run BEFORE the async callback ever can
num = 55;
===
fireDocumentEvent will fire events from the document, so if a developer
went window.addEventListener(...) they would not receive document events,
and vice-versa. The choice is arbitrary.
On Wed, Oct 3, 2018 at 7:46 AM Michael Gatto <mg...@vinsuite.com> wrote:
> Hello All,
>
> I’m trying to better understand a few things regarding Cordova iOS’s JS
> events.
>
> * Why do we need setTimeout with some events?
> * Are there any advantages to using fireDocumentEvent compared to
> fireWindowEvent?
>
>
> Thanks,
> --
> Michael Gatto
>
>
>