Skip to content

Commit

Permalink
feat: buildRegFn add reset func
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Oct 11, 2023
1 parent 18bc2ed commit af16ebe
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/shared/manager/buildReg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function buildRegFn<F extends (...args: any[]) => any>(
name: string,
defaultFunc?: F
) {
let func: F;
let func: F | undefined;

const get = (...args: Parameters<F>): ReturnType<F> => {
if (!func) {
Expand All @@ -26,7 +26,11 @@ export function buildRegFn<F extends (...args: any[]) => any>(
func = fn;
};

return [get, set] as const;
const reset = (): void => {
func = defaultFunc;
};

return [get, set, reset] as const;
}

/**
Expand Down

0 comments on commit af16ebe

Please sign in to comment.