@samitouri / QOSami-HFS / commits / 91fff60a

bad params calling config subscriber

Massimo Melina committed Oct 8, 2023 at 15:36 UTC 91fff60a3bf9d15fee36b0e94e2109e3626d7a77
1 file changed +3 -3
src/config.ts
+3 -3
@@ -72,10 +72,10 @@ export function defineConfig<T, CT=T>(k: string, defaultValue: T, compiler?: Sub
72 cb(getConfig(k), { k, was: defaultValue, defaultValue, version: configVersion.compiled() })
73 const eventName = CONFIG_CHANGE_EVENT_PREFIX + k
74 return onOff(cfgEvents, {
75 - [eventName]() {
75 + [eventName](v, was, version) {
76 if (stack.includes(cb)) return // avoid infinite loop in case a subscriber changes the value
77 - stack.push(cb) // @ts-ignore arguments
78 - try { return cb.apply(this,arguments) }
77 + stack.push(cb)
78 + try { return cb(v, { k, was, version, defaultValue }) }
79 finally { stack.pop() }
80 }
81 })