Skip to content

Commit

Permalink
fix: remove parent from emitter callback
Browse files Browse the repository at this point in the history
  • Loading branch information
pylixonly committed Oct 12, 2024
1 parent 019fdc2 commit fe937a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/lib/api/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function createProxy(target: any = {}): { proxy: any; emitter: Emitter; }

if (value !== undefined && value !== null) {
emitter.emit("GET", {
parent: parentTarget,
path: newPath,
value,
});
Expand Down Expand Up @@ -56,7 +55,6 @@ export function createProxy(target: any = {}): { proxy: any; emitter: Emitter; }
}

emitter.emit("SET", {
parent: parentTarget,
path: [...path, prop],
value: target[prop],
});
Expand All @@ -70,7 +68,6 @@ export function createProxy(target: any = {}): { proxy: any; emitter: Emitter; }
if (success)
emitter.emit("DEL", {
value,
parent: parentTarget,
path: [...path, prop],
});
return success;
Expand Down
5 changes: 2 additions & 3 deletions src/lib/utils/Emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ export type EmitterEvent = "SET" | "GET" | "DEL";

export interface EmitterListenerData {
path: string[];
value: any;
parent: any;
value?: any;
}

export type EmitterListener = (
event: EmitterEvent,
data: EmitterListenerData | any
) => any;

export type EmitterListeners = Record<string, Set<EmitterListener>>
export type EmitterListeners = Record<string, Set<EmitterListener>>;

export class Emitter {
listeners = Object.values(Events).reduce<EmitterListeners>(
Expand Down

0 comments on commit fe937a4

Please sign in to comment.