Skip to content

Commit f41e957

Browse files
Updates typings allowing multiple event listener parameters
1 parent a164cb4 commit f41e957

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

source/interfaces/unity-context-event-map.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default interface IUnityContextEventMap {
1212
* is fully loaded into memory and will start execution, the progression will
1313
* hit 1. The event will invoke everytime the progression advances.
1414
*/
15-
progress: number;
15+
progress: [number];
1616

1717
/**
1818
* While your application is being downloaded from the server and loaded into
@@ -21,7 +21,7 @@ export default interface IUnityContextEventMap {
2121
* is emitted when the Unity player is loaded into memory and execution is
2222
* started. Event will be invoked only once.
2323
*/
24-
loaded: void;
24+
loaded: [void];
2525

2626
/**
2727
* When your Applications run into a runtime error, you might want to display
@@ -31,12 +31,12 @@ export default interface IUnityContextEventMap {
3131
* runtime error. The error details and stack trace are passed along via the
3232
* parameter.
3333
*/
34-
error: string;
34+
error: [string];
3535

3636
/**
3737
* The quitted event is emitted in two cases, when the Unity component is
3838
* unmounted, and when Application.Quit is invoked from within your Unity
3939
* Application. In both cases the Unity Player will be unloaded from memory.
4040
*/
41-
quitted: void;
41+
quitted: [void];
4242
}

source/models/unity-context.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,18 @@ export default class UnityContext {
8787
* @param {string} eventName the event name
8888
* @param {Function} eventListener the event function
8989
* @returns {any} The Function
90-
*
9190
*/
9291
public on<MapKey extends keyof IUnityContextEventMap | (string & {})>(
9392
eventName: keyof IUnityContextEventMap | (MapKey & {}),
9493
eventListener: (
95-
parameter: MapKey extends keyof IUnityContextEventMap
94+
...parameters: MapKey extends keyof IUnityContextEventMap
9695
? IUnityContextEventMap[MapKey]
9796
: any
9897
) => void
9998
): void {
10099
this.unityEvents.push({ eventName, eventCallback: eventListener });
101-
(window as any).ReactUnityWebGL[eventName] = (parameter: any) =>
102-
eventListener(parameter);
100+
(window as any).ReactUnityWebGL[eventName] = (...parameters: any) =>
101+
eventListener(...parameters);
103102
}
104103

105104
/**

0 commit comments

Comments
 (0)