Hello all,
I'm in the process of writing plugins to expose BlackBerry 10 APIs to Construct 2 developers. Everything has gone smoothly until now as the process has been:
Invoke API.
Let API do its thing.
API finishes, trigger Conditions to allow response Actions.
Now I need to make the returned values accessible to the developer so they can leverage the data in their own logic.
For example, I am calling an API that returns an array of Purchases (i.e. things the end-user has bought for the application.)
<pre 100> /* Action: getExistingPurchases */
Acts.prototype.getExistingPurchases = function () {
var _this = this;
if (typeof blackberry !== 'undefined') {
?blackberry.payment.getExistingPurchases(
true,
function onSuccess(data) {
_this.callbackArgs = data;
_this.runtime.trigger(cr.plugins_.blackberry10.prototype.cnds.onGetPurchasesSuccess, _this);
},
function onFailure(error) {
_this.callbackArgs = error;
_this.runtime.trigger(cr.plugins_.blackberry10.prototype.cnds.onGetPurchasesFailure, _this);
}
?);
}
};</pre>On success (or failure) the functions trigger a Condition to allow certain actions to take place. But at that point, it seems to me that data (or _this.callbackArgs) is simply lost. Most of the time the developer will want to loop through the results on their own and take actions (i.e. ensuring a purchased level is unlocked, etc.) but I'm just not sure how to make that accessible to them.
Does anyone happen to have any insight here? If I can clarify at all, please let me know.
I just don't see how to bridge the gap between a developer needing to use the data, and having the data in a callback function of my plugin. I feel Expressions may be involved here but haven't found a proper path forward.