Skip to content

Commit 8197d57

Browse files
committed
Update proxy's get trap
1 parent ffca2f2 commit 8197d57

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/getFlagsProxy.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,14 @@ function hasFlag(flags: LDFlagSet, flagKey: string) {
5353
function toFlagsProxy(ldClient: LDClient, flags: LDFlagSet, flagKeyMap: LDFlagKeyMap): LDFlagSet {
5454
return new Proxy(flags, {
5555
// trap for reading a flag value that refreshes its value with `LDClient#variation` to trigger an evaluation event
56-
get(target, prop) {
57-
const flagKey = prop.toString();
58-
const currentValue = Reflect.get(target, flagKey);
56+
get(target, flagKey: string, reciever) {
57+
const currentValue = Reflect.get(target, flagKey, reciever);
5958
if (currentValue === undefined) {
6059
return;
6160
}
6261
const originalFlagKey = hasFlag(flagKeyMap, flagKey) ? flagKeyMap[flagKey] : flagKey;
6362
const nextValue = ldClient.variation(originalFlagKey, currentValue);
64-
Reflect.set(target, flagKey, nextValue);
63+
Reflect.set(target, flagKey, nextValue, reciever);
6564

6665
return nextValue;
6766
},

0 commit comments

Comments
 (0)