You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Takashi Okamoto (Created) (JIRA)" <ji...@apache.org> on 2012/03/05 04:09:34 UTC

[jira] [Created] (CB-296) Cordova.hasResouce doesn't work for Android

Cordova.hasResouce doesn't work for Android
-------------------------------------------

                 Key: CB-296
                 URL: https://issues.apache.org/jira/browse/CB-296
             Project: Apache Callback
          Issue Type: Bug
          Components: Android
    Affects Versions: 1.5.0
         Environment: Android
            Reporter: Takashi Okamoto
            Assignee: Joe Bowser


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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (CB-296) Cordova.hasResouce doesn't work for Android

Posted by "Filip Maj (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Filip Maj closed CB-296.
------------------------

    Resolution: Won't Fix
      Assignee: Filip Maj  (was: Joe Bowser)

hasResource is not part of the core API (see the docs).

In 1.5 for the Android implementation, we moved to using the Android build of the Cordova-JS project, a unified JavaScript layer for all Cordova platforms. You can find that project here:

https://github.com/apache/incubator-cordova-js

P.S. hasResource's implementation was literally:

{code:javascript}
function hasResource(res) {
  return (window.plugins[res] !== undefined);
}
{code}

... which you can now check by calling require() on a specific plugin and seeing if it returns a truthy value.
                
> Cordova.hasResouce doesn't work for Android
> -------------------------------------------
>
>                 Key: CB-296
>                 URL: https://issues.apache.org/jira/browse/CB-296
>             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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CB-296) Cordova.hasResouce doesn't work for Android

Posted by "Patrick Mueller (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13222363#comment-13222363 ] 

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:

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

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: https://issues.apache.org/jira/browse/CB-296
>             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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira