From 4766f2b1a29a128b47a9c0e740f8e9c4f35e7113 Mon Sep 17 00:00:00 2001 From: Alex Kanunnikov Date: Wed, 15 May 2024 19:56:17 +0300 Subject: [PATCH] + --- src/utils/reactive.ts | 59 ++++++++++++++++++++++--------------- src/utils/redux-devtools.ts | 2 +- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/utils/reactive.ts b/src/utils/reactive.ts index 9a018091..477175c8 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 df688222..cf460b7b 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 ){