Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 13
Registered: ‎10-06-2013
My Device: q10
My Carrier: 33663190794
Accepted Solution

[CORDOVA] Plugin conversion

Hello,

 

i'm converting some of my old bb10 webworks plugin to cordova plugin but i don't know what is the equivalent to :

 

window.webworks.execAsync in cordova.

 

because i think cordova.exec is synchronous.

BlackBerry Development Advisor
Posts: 203
Registered: ‎12-18-2012
My Device: Z10, Q10, Q5, Z30, Z3
My Carrier: Bell

Re: [CORDOVA] Plugin conversion

cordova.exec is asyncronous

Bryan Higgins
BlackBerry WebWorks
@bryanhiggins
Contributor
Posts: 13
Registered: ‎10-06-2013
My Device: q10
My Carrier: 33663190794

Re: [CORDOVA] Plugin conversion

ok thanks for the precision.

 

BlackBerry Development Advisor
Posts: 835
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: [CORDOVA] Plugin conversion

We have a template for Cordova Plugins up here that shows how to do several types of function call:

 

https://github.com/blackberry/WebWorks-Community-APIs/tree/master/BB10-Cordova/Template

Tim Windsor
Open Source Technical Lead
Contributor
Posts: 13
Registered: ‎10-06-2013
My Device: q10
My Carrier: 33663190794

Re: [CORDOVA] Plugin conversion

An other question about event :

 

with webworks plugins it was natural to do tis kind of code :

 

_event = require("../../lib/event");

 

self.onEvent = function (jdata) {
...
_event.trigger("myplugin", JSON.parse(jdata));

 

But when i look to cordova port of blackberry plugin like sensors the "lib/event" is not use

the comunication between client.js and "JNEXT part" is done y using callback.

 

do you think i can continue to use the lib/events in my plugin or it would be better that I make the same way blackberry's cordova plugin (like sensor)

BlackBerry Development Advisor
Posts: 835
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: [CORDOVA] Plugin conversion

You should switch to the cordova callback method. The Template shows how that works, by creating a new PluginResult object when the function is called in index.js, storing this object and sending it's callbackId value down to the native layer. The native layer uses that callbackId as it's event name when sending results back, and the object is looked up.

Tim Windsor
Open Source Technical Lead