You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Benn Mapes <be...@gmail.com> on 2013/06/26 01:12:31 UTC

[cordova-js] Order of internal cordova events and docs

Not sure if this is doc'ed anywhere, I looked on the wiki but I didn't see
anything.

Currently the order of events for page-load/cordova start-up is this (on
windows phone):
1.) onDOMContentLoaded
2.) onPluginsReady
3.) onNativeReady
4.) onCordovaReady
5.) onCordovaInfoReady
6.) deviceready

After digging though some old mailing lists I found this mention about the
topic [1].

For plugins on windows phone we need to patch the browser and inject some
scripts so that the xhr will run, this is hard to do if onPluginsReady gets
fired before onNativeReady because we have no way to ensure that the xhr is
patched before the plugins get loaded.

What do people think about documenting the order of these events firing so
that it will be consistent across all platforms, as well as waiting for
onNativeReady to fire before loading the plugins?


[1]:
http://callback.markmail.org/message/bziya43ztqo6oqrs?q=cordova+list:org%2Eapache%2Eincubator%2Ecallback-dev+order+channel+fire

Re: [cordova-js] Order of internal cordova events and docs

Posted by Jesse <pu...@gmail.com>.
Yes, +1, the event order needs to be formalized.
Patching the XHR loading of local plugins is hopelessly hooped without this.
... as well as any XHR calls to local files that may happen before
deviceready.





@purplecabbage
risingj.com


On Tue, Jun 25, 2013 at 4:12 PM, Benn Mapes <be...@gmail.com> wrote:

> Not sure if this is doc'ed anywhere, I looked on the wiki but I didn't see
> anything.
>
> Currently the order of events for page-load/cordova start-up is this (on
> windows phone):
> 1.) onDOMContentLoaded
> 2.) onPluginsReady
> 3.) onNativeReady
> 4.) onCordovaReady
> 5.) onCordovaInfoReady
> 6.) deviceready
>
> After digging though some old mailing lists I found this mention about the
> topic [1].
>
> For plugins on windows phone we need to patch the browser and inject some
> scripts so that the xhr will run, this is hard to do if onPluginsReady gets
> fired before onNativeReady because we have no way to ensure that the xhr is
> patched before the plugins get loaded.
>
> What do people think about documenting the order of these events firing so
> that it will be consistent across all platforms, as well as waiting for
> onNativeReady to fire before loading the plugins?
>
>
> [1]:
>
> http://callback.markmail.org/message/bziya43ztqo6oqrs?q=cordova+list:org%2Eapache%2Eincubator%2Ecallback-dev+order+channel+fire
>

Re: [cordova-js] Order of internal cordova events and docs

Posted by Ian Clelland <ic...@google.com>.
There is not a well-defined order, but there is a partial ordering of
events. The two hard-coded dependencies are these:

deviceready <- (onCordovaReady, DOMContentLoaded) + plugin-defined
dependencies
onCordovaReady <- (onNativeReady, onPluginsReady)

However, because plugins can add themselves to the list of deviceready
dependencies, and they depend on onCordovaReady, in practice the graph
looks like this (the last time I checked, at least):

deviceready <- (DOMContentLoaded, onCordovaInfoReady,
onCordovaConnectionReady)
onCordovaInfoReady <- onCordovaReady
onCordovaConnectionReady <- onCordovaReady
onCordovaReady <- (onNativeReady, onPluginsReady)

This should probably be documented somewhere.


On Wed, Jun 26, 2013 at 12:54 PM, Filip Maj <fi...@adobe.com> wrote:

> I agree with Andrew, the order shouldn't be set in stone. WE should
> definitely _list_ the events and explain what each channel should
> represent, but IMO forcing a particular event order is make-work for a lot
> of platforms and offers no real benefit.
>
> On 6/25/13 4:25 PM, "Andrew Grieve" <ag...@chromium.org> wrote:
>
> >The order isn't meant to be serially defined. Many platforms fire
> >onNativeReady as the first channel fired. Some do have dependencies
> >though,
> >and you can see them in code by looking for where channel.join() is
> >called.
> >
> >Your options:
> >If you want your code to run as soon as possible, you should put it in
> >your
> >bootstrap.js file.
> >
> >platform.js is another target, but that won't fire until after
> >onPluginsReady
> >
> >onPluginsReady() is meant to be fired once all the plugin file modules are
> >available, but before any plugin modules are require()d. Looks like
> >there's
> >a bug right now in that plugins with <runs/> tags are being run before
> >onPluginsReady() is fired. This will cause their require()s to possible
> >fail and we should fix that.
> >
> >platform.initialize() also waits for onNativeReady. I somewhat doubt that
> >it needs to, but it does.
> >
> >
> >
> >On Tue, Jun 25, 2013 at 7:12 PM, Benn Mapes <be...@gmail.com> wrote:
> >
> >> Not sure if this is doc'ed anywhere, I looked on the wiki but I didn't
> >>see
> >> anything.
> >>
> >> Currently the order of events for page-load/cordova start-up is this (on
> >> windows phone):
> >> 1.) onDOMContentLoaded
> >> 2.) onPluginsReady
> >> 3.) onNativeReady
> >> 4.) onCordovaReady
> >> 5.) onCordovaInfoReady
> >> 6.) deviceready
> >>
> >> After digging though some old mailing lists I found this mention about
> >>the
> >> topic [1].
> >>
> >> For plugins on windows phone we need to patch the browser and inject
> >>some
> >> scripts so that the xhr will run, this is hard to do if onPluginsReady
> >>gets
> >> fired before onNativeReady because we have no way to ensure that the
> >>xhr is
> >> patched before the plugins get loaded.
> >>
> >> What do people think about documenting the order of these events firing
> >>so
> >> that it will be consistent across all platforms, as well as waiting for
> >> onNativeReady to fire before loading the plugins?
> >>
> >>
> >> [1]:
> >>
> >>
> >>
> http://callback.markmail.org/message/bziya43ztqo6oqrs?q=cordova+list:org%
> >>2Eapache%2Eincubator%2Ecallback-dev+order+channel+fire
> >>
>
>

Re: [cordova-js] Order of internal cordova events and docs

Posted by Jesse MacFadyen <pu...@gmail.com>.
Nevermind then, I'll just have to hack something together.

Cheers,
  Jesse

Sent from my iPhone5

On Jun 26, 2013, at 9:55 AM, Filip Maj <fi...@adobe.com> wrote:

I agree with Andrew, the order shouldn't be set in stone. WE should
definitely _list_ the events and explain what each channel should
represent, but IMO forcing a particular event order is make-work for a lot
of platforms and offers no real benefit.

> On 6/25/13 4:25 PM, "Andrew Grieve" <ag...@chromium.org> wrote:
>
> The order isn't meant to be serially defined. Many platforms fire
> onNativeReady as the first channel fired. Some do have dependencies
> though,
> and you can see them in code by looking for where channel.join() is
> called.
>
> Your options:
> If you want your code to run as soon as possible, you should put it in
> your
> bootstrap.js file.
>
> platform.js is another target, but that won't fire until after
> onPluginsReady
>
> onPluginsReady() is meant to be fired once all the plugin file modules are
> available, but before any plugin modules are require()d. Looks like
> there's
> a bug right now in that plugins with <runs/> tags are being run before
> onPluginsReady() is fired. This will cause their require()s to possible
> fail and we should fix that.
>
> platform.initialize() also waits for onNativeReady. I somewhat doubt that
> it needs to, but it does.
>
>
>
>> On Tue, Jun 25, 2013 at 7:12 PM, Benn Mapes <be...@gmail.com> wrote:
>>
>> Not sure if this is doc'ed anywhere, I looked on the wiki but I didn't
>> see
>> anything.
>>
>> Currently the order of events for page-load/cordova start-up is this (on
>> windows phone):
>> 1.) onDOMContentLoaded
>> 2.) onPluginsReady
>> 3.) onNativeReady
>> 4.) onCordovaReady
>> 5.) onCordovaInfoReady
>> 6.) deviceready
>>
>> After digging though some old mailing lists I found this mention about
>> the
>> topic [1].
>>
>> For plugins on windows phone we need to patch the browser and inject
>> some
>> scripts so that the xhr will run, this is hard to do if onPluginsReady
>> gets
>> fired before onNativeReady because we have no way to ensure that the
>> xhr is
>> patched before the plugins get loaded.
>>
>> What do people think about documenting the order of these events firing
>> so
>> that it will be consistent across all platforms, as well as waiting for
>> onNativeReady to fire before loading the plugins?
>>
>>
>> [1]:
>>
>>
>> http://callback.markmail.org/message/bziya43ztqo6oqrs?q=cordova+list:org%
>> 2Eapache%2Eincubator%2Ecallback-dev+order+channel+fire

Re: [cordova-js] Order of internal cordova events and docs

Posted by Filip Maj <fi...@adobe.com>.
I agree with Andrew, the order shouldn't be set in stone. WE should
definitely _list_ the events and explain what each channel should
represent, but IMO forcing a particular event order is make-work for a lot
of platforms and offers no real benefit.

On 6/25/13 4:25 PM, "Andrew Grieve" <ag...@chromium.org> wrote:

>The order isn't meant to be serially defined. Many platforms fire
>onNativeReady as the first channel fired. Some do have dependencies
>though,
>and you can see them in code by looking for where channel.join() is
>called.
>
>Your options:
>If you want your code to run as soon as possible, you should put it in
>your
>bootstrap.js file.
>
>platform.js is another target, but that won't fire until after
>onPluginsReady
>
>onPluginsReady() is meant to be fired once all the plugin file modules are
>available, but before any plugin modules are require()d. Looks like
>there's
>a bug right now in that plugins with <runs/> tags are being run before
>onPluginsReady() is fired. This will cause their require()s to possible
>fail and we should fix that.
>
>platform.initialize() also waits for onNativeReady. I somewhat doubt that
>it needs to, but it does.
>
>
>
>On Tue, Jun 25, 2013 at 7:12 PM, Benn Mapes <be...@gmail.com> wrote:
>
>> Not sure if this is doc'ed anywhere, I looked on the wiki but I didn't
>>see
>> anything.
>>
>> Currently the order of events for page-load/cordova start-up is this (on
>> windows phone):
>> 1.) onDOMContentLoaded
>> 2.) onPluginsReady
>> 3.) onNativeReady
>> 4.) onCordovaReady
>> 5.) onCordovaInfoReady
>> 6.) deviceready
>>
>> After digging though some old mailing lists I found this mention about
>>the
>> topic [1].
>>
>> For plugins on windows phone we need to patch the browser and inject
>>some
>> scripts so that the xhr will run, this is hard to do if onPluginsReady
>>gets
>> fired before onNativeReady because we have no way to ensure that the
>>xhr is
>> patched before the plugins get loaded.
>>
>> What do people think about documenting the order of these events firing
>>so
>> that it will be consistent across all platforms, as well as waiting for
>> onNativeReady to fire before loading the plugins?
>>
>>
>> [1]:
>>
>> 
>>http://callback.markmail.org/message/bziya43ztqo6oqrs?q=cordova+list:org%
>>2Eapache%2Eincubator%2Ecallback-dev+order+channel+fire
>>


Re: [cordova-js] Order of internal cordova events and docs

Posted by Andrew Grieve <ag...@chromium.org>.
The order isn't meant to be serially defined. Many platforms fire
onNativeReady as the first channel fired. Some do have dependencies though,
and you can see them in code by looking for where channel.join() is called.

Your options:
If you want your code to run as soon as possible, you should put it in your
bootstrap.js file.

platform.js is another target, but that won't fire until after
onPluginsReady

onPluginsReady() is meant to be fired once all the plugin file modules are
available, but before any plugin modules are require()d. Looks like there's
a bug right now in that plugins with <runs/> tags are being run before
onPluginsReady() is fired. This will cause their require()s to possible
fail and we should fix that.

platform.initialize() also waits for onNativeReady. I somewhat doubt that
it needs to, but it does.



On Tue, Jun 25, 2013 at 7:12 PM, Benn Mapes <be...@gmail.com> wrote:

> Not sure if this is doc'ed anywhere, I looked on the wiki but I didn't see
> anything.
>
> Currently the order of events for page-load/cordova start-up is this (on
> windows phone):
> 1.) onDOMContentLoaded
> 2.) onPluginsReady
> 3.) onNativeReady
> 4.) onCordovaReady
> 5.) onCordovaInfoReady
> 6.) deviceready
>
> After digging though some old mailing lists I found this mention about the
> topic [1].
>
> For plugins on windows phone we need to patch the browser and inject some
> scripts so that the xhr will run, this is hard to do if onPluginsReady gets
> fired before onNativeReady because we have no way to ensure that the xhr is
> patched before the plugins get loaded.
>
> What do people think about documenting the order of these events firing so
> that it will be consistent across all platforms, as well as waiting for
> onNativeReady to fire before loading the plugins?
>
>
> [1]:
>
> http://callback.markmail.org/message/bziya43ztqo6oqrs?q=cordova+list:org%2Eapache%2Eincubator%2Ecallback-dev+order+channel+fire
>