incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Coleman <don.cole...@gmail.com>
Subject requiring javascript for plugins
Date Thu, 05 Jul 2012 23:12:24 GMT
Is there a new recommended way to include javascript for plugins?

Previously I just jammed an object onto navigator or a global variable

    navigator.toast = new Toasty();

https://github.com/m00sey/Toasty/blob/f9dbf58e11cf4ecf386f70331960d33e87566dd9/assets/www/phonegap-toast.js

I've rewritten this plugin's javascript as a module and I'm
recommending that the user requires the module in their code with

    var toast = cordova.require('toast');

https://github.com/don/Toasty/blob/bf61ff3c738cebcd285f82490920cf713ac095aa/assets/www/phonegap-toast.js

Is this the recommended way?

It works fine, it's just an extra step for the user, and different
from using a builtin cordova function like
navigator.notification.vibrate.

Should I still assign the plugin code to navigator or cordova?
Is there a way to have my plugin js required by plugin.xml,
cordova.addPlugin or some other function???
Are users to need to require built-in cordova for 2.0+?

Mime
View raw message