incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Maj <...@adobe.com>
Subject Re: JS-Plugin code for cordova 1.6+
Date Tue, 17 Apr 2012 16:26:51 GMT
Nope that looks right. You can use cordova.define to define your plugin
code, inside there you can use cordova.require to require any other
modules of the cordova js, like cordova.require('cordova/exec') to get a
reference to exec, for example.

On 4/17/12 3:02 AM, "Viras" <viras@users.sourceforge.net> wrote:

>I think we are talking about two totally different things here.
>
>Of course the native side uses the passed in success / error callbacks
>(like it was before as well).
>
>I was wondering about how the actual application which uses a
>self-defined plugin should call the plugin-javascript code.
>
>So e.g. in my case the PowerManagement plugin would be called like
>this:
>
>cordova.require('cordova/plugin/powermanagement').acquire(
>					function() { alert( 'hooray' ); },
>					function() { alert( 'oh no!' ); }
>					);
>
>I was just wondering if the
>"cordova.require('cordova/plugin/powermanagement')" is correct or if
>there is any shortcut to the plugin code - but I guess not!
>
>Best,
>Viras
>
>Am 2012-04-17 11:47, schrieb Jesse MacFadyen:
>> The native callback piece will vary by platform, but you should not
>> be
>> calling named JavaScript. Have a look at one of the simpler apis,
>> like
>> Accelerometer.
>>
>> Callbacks should be routed via cordova result/error handler.
>> iOS example here:
>> 
>> 
>>https://github.com/purplecabbage/incubator-cordova-ios/blob/master/Cordov
>>aLib/Classes/CDVAccelerometer.m#L124
>>
>> The result will be passed to the callback function you passed to
>> exec.
>>
>> Cheers,
>>   Jesse
>>
>> Sent from my iPhone5
>>
>> On 2012-04-17, at 1:58 AM, Viras <viras@users.sourceforge.net> wrote:
>>
>>> Nevermind I figured it out myself. Stupid me forgot that plugins
>>> reside outside the actual cordova namespace prefix and therefor I need
>>> to prefix "cordova" to function calls like require, define, etc. :).
>>>
>>> BTW: Should the actual application code use
>>> "cordova.require('whatever').function()" or is there any "shortcut" to
>>> plugins? (since window.plugins is deprecated, right?)
>>>
>>> Best,
>>> Viras
>>>
>>> Am 2012-04-17 10:02, schrieb Viras:
>>>> Hi,
>>>>
>>>> is there some kind of guide on how to design a non-core plugin for
>>>> cordova 1.6+?
>>>>
>>>> I'm a bit confused on how to define a custom plugin code to be
>>>> fully
>>>> compliant to the new scheme. I tried to look up how the core
>>>> plugins
>>>> work but they seem to be statically defined in common/common.js
>>>> which
>>>> is not possible for a non-core plugin (obviously).
>>>>
>>>> I would appreciate any hints!
>>>>
>>>> Best,
>>>> Viras
>>>
>>> --
>>> GOFG - Get On Fat Guy
>>> http://www.gofg.at/ - powered by Cordova
>
>-- 
>GOFG - Get On Fat Guy
>http://www.gofg.at/ - powered by Cordova


Mime
View raw message