Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Wire up electron download progress to toasts #5863

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/hooks/useEventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ limitations under the License.
*/

import {useRef, useEffect} from "react";
import type {EventEmitter} from "events";

type Handler = (...args: any[]) => void;

interface EventEmitter {
on(event: string | symbol, listener: (...args: any[]) => void);
removeListener(event: string | symbol, listener: (...args: any[]) => void);
}

// Hook to wrap event emitter on and removeListener in hook lifecycle
export const useEventEmitter = (emitter: EventEmitter, eventName: string | symbol, handler: Handler) => {
// Create a ref that stores handler
Expand Down