providers documentation
This commit is contained in:
12
lib/qt.js
12
lib/qt.js
@ -21,6 +21,11 @@
|
||||
* @date 2014
|
||||
*/
|
||||
|
||||
/**
|
||||
* QtProvider object prototype is implementing 'provider protocol'
|
||||
* Should be used inside ethereum browser. It's compatible with cpp and go clients.
|
||||
* It uses navigator.qt object to pass the messages to native bindings
|
||||
*/
|
||||
var QtProvider = function() {
|
||||
this.handlers = [];
|
||||
|
||||
@ -32,10 +37,17 @@ var QtProvider = function() {
|
||||
};
|
||||
};
|
||||
|
||||
/// Prototype object method
|
||||
/// Should be called when we want to send single api request to native bindings
|
||||
/// Asynchronous
|
||||
/// Response will be received by navigator.qt.onmessage method and passed to handlers
|
||||
/// @param payload is inner message object
|
||||
QtProvider.prototype.send = function(payload) {
|
||||
navigator.qt.postMessage(JSON.stringify(payload));
|
||||
};
|
||||
|
||||
/// Prototype object property
|
||||
/// Should be used to set message handlers for this provider
|
||||
Object.defineProperty(QtProvider.prototype, "onmessage", {
|
||||
set: function(handler) {
|
||||
this.handlers.push(handler);
|
||||
|
Reference in New Issue
Block a user