Skip to content

Commit

Permalink
Add some defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
mofojed committed Aug 20, 2024
1 parent 58a517a commit 6eb72f7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/golden-layout/src/utils/EventUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type EventListenerHook<TParameters = []> = (
* @param handler The handler to call when the event is emitted
* @returns A function to stop listening for the event
*/
export function listenForEvent<TParameters>(
export function listenForEvent<TParameters = []>(
eventEmitter: EventEmitter,
event: string,
handler: EventHandlerFunction<TParameters>
Expand All @@ -38,22 +38,22 @@ export function listenForEvent<TParameters>(
};
}

export function makeListenFunction<TParameters>(
export function makeListenFunction<TParameters = []>(
event: string
): EventListenFunction<TParameters> {
return (eventEmitter, handler) =>
listenForEvent(eventEmitter, event, handler);
}

export function makeEmitFunction<TParameters>(
export function makeEmitFunction<TParameters = []>(
event: string
): EventEmitFunction<TParameters> {
return (eventEmitter, ...parameters) => {
eventEmitter.emit(event, ...parameters);
};
}

export function makeUseListenerFunction<TParameters>(
export function makeUseListenerFunction<TParameters = []>(
event: string
): EventListenerHook<TParameters> {
return (eventEmitter, handler) => {
Expand All @@ -69,7 +69,9 @@ export function makeUseListenerFunction<TParameters>(
* @param event Name of the event to create functions for
* @returns Listener, Emitter, and Hook functions for the event
*/
export function makeEventFunctions<TParameters>(event: string): {
export function makeEventFunctions<TParameters = []>(
event: string
): {
listen: EventListenFunction<TParameters>;
emit: EventEmitFunction<TParameters>;
useListener: EventListenerHook<TParameters>;
Expand Down

0 comments on commit 6eb72f7

Please sign in to comment.