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

Commit

Permalink
Wire up electron download progress to toasts
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Apr 14, 2021
1 parent ae5b6ef commit 9f4e434
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 9f4e434

Please sign in to comment.