incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Mueller (Commented) (JIRA)" <>
Subject [jira] [Commented] (CB-296) Cordova.hasResouce doesn't work for Android
Date Mon, 05 Mar 2012 14:09:58 GMT


Patrick Mueller commented on CB-296:

bq. ... which you can now check by calling require() on a specific plugin and seeing if it
returns a truthy value.

calling {{require(<some module name>)}} when the specified module is not available will
throw an exception, so ... that's not a good way to check.  This should work:

function hasResource(moduleId) {
    try {
        return require(moduleId)
    catch(e) {
        return false

But what's the use case here?  Maybe this was for a non-core plugin?  How do plugins register
themselves so that some other piece of code can ask if they're loaded?  Do we eventually want
to move them into the module system?  If so, we may want to add an additional API such as
{{cordova.isModuleAvailable(<some module name>)}} which would return a boolean indicating
whether a module was available or not.  Node.js has an API called {{require.resolve(<some
module id>)}}, which resolves a module name to a file name without loading it, but also
throws an error if the module isn't available.
> Cordova.hasResouce doesn't work for Android
> -------------------------------------------
>                 Key: CB-296
>                 URL:
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 1.5.0
>         Environment: Android
>            Reporter: Takashi Okamoto
>            Assignee: Filip Maj
> I tried Cordova.hasResource  with Cordova 1.5.0 snapshot on Android.
> I found Cordova.hasResouce doesn't work and not defined in cordova-1.5.0.js
> cordova.js.base may not include cordova-1.5.0.js and 
> it seems build.xml problem.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message