MCPcopy Index your code
hub / github.com/NativeScript/capacitor / NativeScriptCap

Class NativeScriptCap

testing/testingInterface.ts:19–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19class NativeScriptCap {
20 static listeners = {fromNativeScript: [], toNativeScript: []};
21 static addListener(event, callback) {
22 if (typeof this.listeners[event] === 'undefined') {
23 this.listeners[event] = [];
24 }
25 this.listeners[event].push(callback);
26 }
27
28 static sendResponse(value, event="fromNativeScript") {
29 for (let i=0;i<this.listeners[event].length;i++) {
30 this.listeners[event][i](value);
31 }
32 }
33
34 static notify(data) {
35 this.sendResponse(data, "toNativeScript");
36 }
37
38 /* static notify(data) {
39 let msg = JSON.parse(data.value);
40 if (msg.cmd !== NS_MARSHALL_CONSOLE) {
41 console.log(msg);
42 }
43 switch (msg.cmd) {
44 case NS_MARSHALL_STARTUP:
45 this.sendResponse({
46 tracking: -1,
47 cmd: NS_MARSHALL_PLATFORM,
48 platform: true,
49 });
50 break;
51 case NS_MARSHALL_GET:
52
53
54 case NS_MARSHALL_PLATFORM:
55 case NS_MARSHALL_CONSOLE:
56 console.log(msg.log); break; // complete
57
58
59 case NS_MARSHALL_CALLBACK:
60 console.log("Callback");
61 break;
62
63 default:
64 console.log("Unknown Command", msg.cmd);
65 }
66 } */
67}
68
69(<any>window).test = new test();
70(<any>window).NativeScriptCap = NativeScriptCap;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected