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 <mga...@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
>
>
>

Reply via email to