MCPcopy Create free account
hub / github.com/astercloud/aster / useWatchDataPath

Function useWatchDataPath

ui/src/composables/useAsterDataBinding.ts:177–197  ·  view source on GitHub ↗
(
  path: string,
  callback: (newValue: DataValue | null, oldValue: DataValue | null) => void,
)

Source from the content-addressed store, hash-verified

175 * @returns Stop watching function
176 */
177export function useWatchDataPath(
178 path: string,
179 callback: (newValue: DataValue | null, oldValue: DataValue | null) => void,
180): () => void {
181 const context = inject<DataBindingContext | null>(DATA_BINDING_CONTEXT_KEY, null);
182
183 if (!context) {
184 console.warn('useWatchDataPath: No data binding context found');
185 return () => {};
186 }
187
188 const stopWatch = watch(
189 () => getData(context.dataModel.value, path),
190 (newValue, oldValue) => {
191 callback(newValue, oldValue);
192 },
193 { deep: true },
194 );
195
196 return stopWatch;
197}

Callers

nothing calls this directly

Calls 1

getDataFunction · 0.90

Tested by

no test coverage detected