()
| 104 | _callbacks = []; |
| 105 | |
| 106 | constructor() { |
| 107 | if (NativeScriptProxy.instance) { |
| 108 | return NativeScriptProxy.instance[NS_PROXY]; |
| 109 | } |
| 110 | NativeScriptProxy.instance = this; |
| 111 | |
| 112 | this._id = 0; |
| 113 | this._trackingId = 0; |
| 114 | this._tracking = {}; |
| 115 | |
| 116 | const proxy = this.getProxy(null, 'native', native_handler); |
| 117 | (<any>this)[NS_PROXY] = proxy; |
| 118 | (<any>this)[NS_PROXY_FUNCTION] = proxy.__func; |
| 119 | |
| 120 | // Setup the Listener from NativeScript |
| 121 | (<any>NativeScriptCap).addListener('fromNativeScript', (info: any) => { |
| 122 | this.receiveMessage(info); |
| 123 | }); |
| 124 | |
| 125 | // Let the NS know we are here, fire this after we have returned the proxy object below |
| 126 | setTimeout(() => { |
| 127 | this.sendMessage({ cmd: NS_MARSHALL_STARTUP }); |
| 128 | }, 0); |
| 129 | |
| 130 | return proxy; |
| 131 | } |
| 132 | |
| 133 | sendMessage(msg: any) { |
| 134 | if (DEBUGGING) { |
nothing calls this directly
no test coverage detected