diff --git a/src/utils/reactive.ts b/src/utils/reactive.ts index 9a01809..477175c 100644 --- a/src/utils/reactive.ts +++ b/src/utils/reactive.ts @@ -51,6 +51,32 @@ function keysFor(obj: object): Map> { 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, @@ -120,6 +146,9 @@ export class Cell { this._debugName = debugContext(debugName); DEBUG_CELLS.add(this); } + result.dispatch({ + type: 'CELL_CREATED', + }); } get value() { if (currentTracker !== null) { @@ -134,6 +163,9 @@ export class Cell { this._value = value; tagsToRevalidate.add(this); scheduleRevalidate(); + result.dispatch({ + type: 'CELL_UPDATED', + }); } } @@ -342,27 +374,6 @@ export function setTracker(tracker: Set | 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); - } -}); \ No newline at end of file + + +console.log('result', result); \ No newline at end of file diff --git a/src/utils/redux-devtools.ts b/src/utils/redux-devtools.ts index df68822..cf460b7 100644 --- a/src/utils/redux-devtools.ts +++ b/src/utils/redux-devtools.ts @@ -95,7 +95,7 @@ export function supportChromeExtension( State ){ ? window.__REDUX_DEVTOOLS_EXTENSION__() : (f) => f; - compose( + return compose( FreezerMiddleware( State ), devtools )(createStore)( function( state ){