Skip to content

Commit e1333a9

Browse files
committed
Remove extra logging, add comments clarifying proxy usage in UI
1 parent 75d8c36 commit e1333a9

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

app/store/WithLitLytics.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function WithLitLytics({ children }: { children: React.ReactNode }) {
2828
const [, forceUpdate] = useReducer((x) => x + 1, 0);
2929

3030
// create proxy that triggers state updates
31-
// only create it once
31+
// only create it once and use context to pass it around
3232
useEffect(() => {
3333
if (isInited) {
3434
return;
@@ -55,7 +55,6 @@ export function WithLitLytics({ children }: { children: React.ReactNode }) {
5555
// set inited flag
5656
setIsInited(true);
5757
// assign initial config and webEngine instance
58-
console.log('set', config);
5958
ll.importConfig(config);
6059
ll.setWebEngine(webllm.engine);
6160
}, [isInited, config, webllm, setIsInited, setLitlytics, setConfig]);

app/store/util.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import { LitLytics } from 'litlytics';
22
/* eslint @typescript-eslint/ban-ts-comment: off */
3+
4+
/**
5+
* Creates a Proxy wrapper around LitLytics instance to monitor function invocations
6+
* and update react state upon those invocations completion.
7+
* This is required because React cannot see changes in persistent object (i.e. wants new object refs)
8+
*
9+
* @param instance LitLytics instance
10+
* @param updateCallback callback to update state
11+
* @returns LitLytics instance with a proxy
12+
*/
313
export function createReactiveProxy(
414
instance: LitLytics,
515
updateCallback: () => void
@@ -22,10 +32,5 @@ export function createReactiveProxy(
2232
}
2333
return value;
2434
},
25-
// set(target, prop, value, receiver) {
26-
// const result = Reflect.set(target, prop, value, receiver);
27-
// updateCallback.call(target);
28-
// return result;
29-
// },
3035
});
3136
}

packages/litlytics/litlytics.ts

-2
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,13 @@ export class LitLytics {
131131
}
132132

133133
setPipeline = (newPipeline: Partial<Pipeline>) => {
134-
console.log('set pipeline', newPipeline);
135134
this._pipeline = {
136135
...this._pipeline,
137136
...newPipeline,
138137
};
139138
};
140139

141140
resetPipeline = () => {
142-
console.log('reset pipeline');
143141
this._pipeline = emptyPipeline;
144142
this._pipelineStatus = { status: 'init' };
145143
};

0 commit comments

Comments
 (0)