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 c9f501c commit 4766f2b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
59 changes: 35 additions & 24 deletions src/utils/reactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,32 @@ function keysFor(obj: object): Map<string | number | symbol, 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 @@ -120,6 +146,9 @@ export class Cell<T extends unknown = unknown> {
this._debugName = debugContext(debugName);
DEBUG_CELLS.add(this);
}
result.dispatch({
type: 'CELL_CREATED',
});
}
get value() {
if (currentTracker !== null) {
Expand All @@ -134,6 +163,9 @@ export class Cell<T extends unknown = unknown> {
this._value = value;
tagsToRevalidate.add(this);
scheduleRevalidate();
result.dispatch({
type: 'CELL_UPDATED',
});
}
}

Expand Down Expand Up @@ -342,27 +374,6 @@ export function setTracker(tracker: Set<Cell> | null) {
currentTracker = tracker;
}

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 4766f2b

Please sign in to comment.