Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed May 15, 2024
1 parent 3aed6a5 commit 9998f88
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
8 changes: 5 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 35 additions & 24 deletions src/utils/reactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ function keysFor(obj: object): Record<string, Cell<unknown>> {
return cellsMap.get(obj)!;
}

const result = supportChromeExtension({
get() {
const cells = {};
getCells().forEach((cell, index) => {
cells[`${cell._debugName}:${index}`] = cell._value;
});
// console.log('get', cells);
return cells;
},
skipDispatch: 0,
set() {
console.log('set', ...arguments);
},
on(timeLine: string, fn: () => any) {
console.log('on', timeLine, fn);
setTimeout(() => {
// debugger;
fn.call(this, 'updates', {})

}, 2000);
},
trigger() {
console.log('trigger', ...arguments);
}
});

export function tracked(
klass: any,
key: string,
Expand Down Expand Up @@ -114,6 +140,9 @@ export class Cell<T extends unknown = unknown> {
this._debugName = debugName;
DEBUG_CELLS.add(this);
}
result.dispatch({
type: 'CELL_CREATED',
});
}
get value() {
if (currentTracker !== null) {
Expand All @@ -128,6 +157,9 @@ export class Cell<T extends unknown = unknown> {
this._value = value;
tagsToRevalidate.add(this);
scheduleRevalidate();
result.dispatch({
type: 'CELL_UPDATED',
});
}
}

Expand Down Expand Up @@ -310,27 +342,6 @@ export function inNewTrackingFrame(callback: () => void) {
currentTracker = existingTracker;
}

supportChromeExtension({
get() {
const cells = {};
DEBUG_CELLS.forEach((cell, index) => {
cells[`${cell._debugName}:${index}`] = cell._value;
});
return cells;
},
skipDispatch: 0,
set() {
console.log('set', ...arguments);
},
on(timeLine: string, fn: () => any) {
console.log('on', timeLine, fn);
setTimeout(() => {
// debugger;
fn.call(this, 'updates', {})

}, 2000);
},
trigger() {
console.log('trigger', ...arguments);
}
});


console.log('result', result);
2 changes: 1 addition & 1 deletion src/utils/redux-devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function supportChromeExtension( State ){
? window.__REDUX_DEVTOOLS_EXTENSION__()
: (f) => f;

compose(
return compose(
FreezerMiddleware( State ),
devtools
)(createStore)( function( state ){
Expand Down

0 comments on commit 9998f88

Please sign in to comment.