Skip to content

Commit

Permalink
fix: enableDirectAccess was not going through overridden get
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeistrich committed Oct 12, 2023
1 parent a47c56f commit 0091b8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export {
export { ObservablePrimitiveClass } from './src/ObservablePrimitive';

// Internal:
import { get, getProxy, peek, set } from './src/ObservableObject';
import { get, getProxy, observableFns, peek, set } from './src/ObservableObject';
import { ensureNodeValue, findIDKey, getNode, globalState, optimized, setNodeValue, symbolDelete } from './src/globals';
import { setAtPath } from './src/helpers';

Expand All @@ -65,6 +65,7 @@ export const internal = {
getNode,
getProxy,
globalState,
observableFns,
optimized,
peek,
set,
Expand Down
11 changes: 7 additions & 4 deletions src/config/enableDirectAccess.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { configureLegendState, internal, updateTracking } from '@legendapp/state';
import { configureLegendState, internal, type NodeValue } from '@legendapp/state';

export function enableDirectAccess() {
const { observableFns, set } = internal;
configureLegendState({
observableProperties: {
$: {
get(node) {
updateTracking(node);
return internal.peek(node);
// Get it from the observableFns Map because another config function
// might have overriden get
const get = observableFns.get('get') as (node: NodeValue) => any;
return get(node);
},
set(node, value) {
return internal.set(node, value);
return set(node, value);
},
},
},
Expand Down

0 comments on commit 0091b8a

Please sign in to comment.