diff --git a/index.ts b/index.ts index dccc086f2..abc1d3ff7 100644 --- a/index.ts +++ b/index.ts @@ -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'; @@ -65,6 +65,7 @@ export const internal = { getNode, getProxy, globalState, + observableFns, optimized, peek, set, diff --git a/src/config/enableDirectAccess.ts b/src/config/enableDirectAccess.ts index 2e285ae7d..66a983cb4 100644 --- a/src/config/enableDirectAccess.ts +++ b/src/config/enableDirectAccess.ts @@ -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); }, }, },