Page 1 of 1

evothings and AMD

Posted: 09:41, 25 Aug 2015
by thegecko
Has anyone successfully got the evothings library and cordova working in an AMD-based structure, such as requirejs?

I'd be interested in how this works or if there is a recommended approach.

My tests have shown there are race issues loading the cordova library making it unavailable once all dependencies are require'd.

Cheers

Re: evothings and AMD

Posted: 10:56, 25 Aug 2015
by psvensson
Hi @thegecko, there's no apparent reason why AMD couldn't be used to load both cordova and Evothings specific libraries.

Could you tell us more about your test setup? Do you load cordova directly, or do you shim it in AMD, do you let AMD/requireJS load each module dependency dynamically or are you using a build system? A link to the project would be great - if possible ^_^

Cheers,
PS

Re: evothings and AMD

Posted: 11:16, 25 Aug 2015
by micke
We did a "home-grown" async script loading system for the libraries used by the Evothings example apps. (See file evothings.js - https://github.com/evothings/evothings- ... othings.js)

However, this system does not use modules, still just one global address space as with script tags.

Would be much nicer with something like require.js, we looked into it, but at the time it was a too big step to implement in all examples.

We have been discussing Ionic lately, do they use any kind of async module definition? They are based on Cordova and use Angular, perhaps they have figured it out?

Lets continue looking into this.

Best, Mikael

Re: evothings and AMD

Posted: 11:41, 25 Aug 2015
by micke
Peter just told me Ionic/Angular don't have async module support.
Best, Mikael

Re: evothings and AMD

Posted: 12:54, 25 Aug 2015
by thegecko
@psvensson I tried both cordova shimming and globals and saw race conditions or deviceready timeouts with both.
Ideally I'd prefer to go all in and shim cordova, but the most stable test was keeping it global.

I just wondered if someone had got this working in a reliable manner.

@micke with so many frameworks out there, going all in on one may be a dangerous approach. At least with AMD support hte developer should be able to pick and choose their frameworks :)

Cheers!

Re: evothings and AMD

Posted: 12:23, 26 Aug 2015
by psvensson
HI again! Creating a Evothings example using RequireJS/AMD is probably not we will do near-term, since we're quite busy creating the next version of Evo.

I did find an article describing known issues with Cordova and AMD; https://www.nothing.ch/en/research/usin ... n-phonegap

It looks like avoiding dynamic loading (which you'd do in a release/build step anyway) is key to avoiding problems.

HTH,

Cheers.
PS

Re: evothings and AMD

Posted: 18:56, 26 Aug 2015
by thegecko
thanks!