From fe937a4ab5631a0bb23706794511598770015e09 Mon Sep 17 00:00:00 2001 From: pylixonly <82711525+pylixonly@users.noreply.github.com> Date: Sat, 12 Oct 2024 23:19:55 +0800 Subject: [PATCH] fix: remove parent from emitter callback --- src/lib/api/storage/index.ts | 3 --- src/lib/utils/Emitter.ts | 5 ++--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib/api/storage/index.ts b/src/lib/api/storage/index.ts index 8eadd95..9715a39 100644 --- a/src/lib/api/storage/index.ts +++ b/src/lib/api/storage/index.ts @@ -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, }); @@ -56,7 +55,6 @@ export function createProxy(target: any = {}): { proxy: any; emitter: Emitter; } } emitter.emit("SET", { - parent: parentTarget, path: [...path, prop], value: target[prop], }); @@ -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; diff --git a/src/lib/utils/Emitter.ts b/src/lib/utils/Emitter.ts index 5af65ad..7a3cb43 100644 --- a/src/lib/utils/Emitter.ts +++ b/src/lib/utils/Emitter.ts @@ -8,8 +8,7 @@ export type EmitterEvent = "SET" | "GET" | "DEL"; export interface EmitterListenerData { path: string[]; - value: any; - parent: any; + value?: any; } export type EmitterListener = ( @@ -17,7 +16,7 @@ export type EmitterListener = ( data: EmitterListenerData | any ) => any; -export type EmitterListeners = Record> +export type EmitterListeners = Record>; export class Emitter { listeners = Object.values(Events).reduce(