Skip to content

Commit 213068f

Browse files
Added execCommand return type
1 parent 4beea95 commit 213068f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"scripts": {
1818
"build": "tsc",
1919
"watch": "tsc -w",
20-
"prepublishOnly": "tsc"
20+
"prepack": "tsc"
2121
},
2222
"dependencies": {
2323
"event-target-shim": "^5.0.1"

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const RNUnityEventEmitter = new NativeEventEmitter(RNUnity);
1515
class UnityManager extends EventTarget {
1616
private handshake: UnityCommand | null = null;
1717
private handshakeResolved: boolean = false;
18-
private commandsMap: { [id: number]: UnityCommand } = {};
18+
private commandsMap: { [id: number]: UnityCommand<any> } = {};
1919
private commandsIdIterator: number = 0;
2020

2121
constructor() {
@@ -44,9 +44,9 @@ class UnityManager extends EventTarget {
4444
return this.handshake.promise;
4545
}
4646

47-
execCommand(name: string, data?: object) {
47+
execCommand<R = undefined>(name: string, data?: object) {
4848
const id = ++this.commandsIdIterator;
49-
const command = new UnityCommand(id, name, data);
49+
const command = new UnityCommand<R>(id, name, data);
5050

5151
this.commandsMap[id] = command;
5252
this.invokeCommand(command.getMessage());
@@ -105,12 +105,12 @@ class UnityManager extends EventTarget {
105105
}
106106
}
107107

108-
class UnityCommand {
108+
class UnityCommand<R = undefined> {
109109
private id: number | null = null;
110110
private name: string | null = null;
111111
private data: object | null = null;
112112

113-
promise: Promise<any>;
113+
promise: Promise<R>;
114114
resolve: (result?: any) => void;
115115
reject: (result?: any) => void;
116116

0 commit comments

Comments
 (0)