[Utils] Interface for JavaScript <-> native communication.
[Message]
xwalk.utils.native prototype:
- callSync(cmd, args)
- call(cmd, args, callback)
- addListener(name, callback)
- removeListener(name)
and helpers to check/handle native response:
- isSuccess(result)
- isFailure(result)
- getResultObject(result)
- getErrorObject(result)
[Example]
var native_ = new xwalk.utils.NativeManager(extension);
SomeExtension.prototype.someAsyncMethod = function(id, onsuccess, onerror) {
native_.call('SomeExtension.getElement', {
id: id
}, function(result) {
if (native_.isFailure(result)) {
onerror(native_.getErrorObject(result));
} else {
var data = native_.getResultObject();
// conversion to appropriate API type
var item = new tizen.SomeExtensionItem(data);
onsuccess(item);
}
});
};
Change-Id: I867816be8ec78e5791c36dac0e6cced9f7567474