@@ -15,7 +15,7 @@ const RNUnityEventEmitter = new NativeEventEmitter(RNUnity);
15
15
class UnityManager extends EventTarget {
16
16
private handshake : UnityCommand | null = null ;
17
17
private handshakeResolved : boolean = false ;
18
- private commandsMap : { [ id : number ] : UnityCommand } = { } ;
18
+ private commandsMap : { [ id : number ] : UnityCommand < any > } = { } ;
19
19
private commandsIdIterator : number = 0 ;
20
20
21
21
constructor ( ) {
@@ -44,9 +44,9 @@ class UnityManager extends EventTarget {
44
44
return this . handshake . promise ;
45
45
}
46
46
47
- execCommand ( name : string , data ?: object ) {
47
+ execCommand < R = undefined > ( name : string , data ?: object ) {
48
48
const id = ++ this . commandsIdIterator ;
49
- const command = new UnityCommand ( id , name , data ) ;
49
+ const command = new UnityCommand < R > ( id , name , data ) ;
50
50
51
51
this . commandsMap [ id ] = command ;
52
52
this . invokeCommand ( command . getMessage ( ) ) ;
@@ -105,12 +105,12 @@ class UnityManager extends EventTarget {
105
105
}
106
106
}
107
107
108
- class UnityCommand {
108
+ class UnityCommand < R = undefined > {
109
109
private id : number | null = null ;
110
110
private name : string | null = null ;
111
111
private data : object | null = null ;
112
112
113
- promise : Promise < any > ;
113
+ promise : Promise < R > ;
114
114
resolve : ( result ?: any ) => void ;
115
115
reject : ( result ?: any ) => void ;
116
116
0 commit comments