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

Native Development

Reply
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

navigator.cascades.postMessage synchronous call

i have a to call a c++ function from javascript function(say mainJsFunction) which i call using "navigator.cascades.postMessage(param)"

 

function mainJsFunction () {
	var abc= ...
	// some code to be executed 
	naviator.cascades.postMessage (abc);
	// some more processing 
	// i store the value in localStorage element as i cannot get a return value in navigator.cascades.postMessage();
	executed first
	
}

 


In my js function i have some more code to be executed after call to c++ .

 

c++ function will return some value which i have to use my rest of code, that i store in localstorage using signal and slot.

 

But the rest of code is executed first and then the slot javascript function.

 

Is there any way to call the slot javascript function before mainJsFunction ?

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: navigator.cascades.postMessage synchronous call

can't you move the additional processing to the result slot of the c++ processing?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: navigator.cascades.postMessage synchronous call

No i cannot move. mainJsFunction is called from a html page and is expecting a return of value. and that depends on the processing of returned value from c++
Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: navigator.cascades.postMessage synchronous call

i understood that, but a synchronous call seems not to be possible.

you end mainJsFunction at the point where you call the c++ code, then have another function that is called by the c++ code with the result where you continue your processing.
(not sure if that works, never worked with c++/html js bridge)
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: navigator.cascades.postMessage synchronous call

My call is --)  HTML/js with return to mainJsFunction then to c++ function and then another js function (to set value in localStorage). 

 

But after call to c++ function, mainJsFunction executes completely followed by HTML/js call and then comes the another js function (which has to be executed first just after c++ call).