@ngneat/elf-devtools
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -5,2 +5,11 @@ # Changelog | ||
# [1.1.0](https://github.com/ngneat/elf/compare/devtools-1.0.2...devtools-1.1.0) (2021-12-01) | ||
### Features | ||
* **devtools:** 🔥 support timeline ([2d0d303](https://github.com/ngneat/elf/commit/2d0d3037c78ede007d7821467dfe7471aaadc7f5)) | ||
## [1.0.2](https://github.com/ngneat/elf/compare/devtools-1.0.1...devtools-1.0.2) (2021-11-30) | ||
@@ -7,0 +16,0 @@ |
import { skip } from 'rxjs/operators'; | ||
import { getRegistry, registry$, capitalize, getStoresSnapshot } from '@ngneat/elf'; | ||
import { getRegistry, registry$, capitalize, getStoresSnapshot, getStore } from '@ngneat/elf'; | ||
function devTools(options = {}) { | ||
if (!window.__REDUX_DEVTOOLS_EXTENSION__) return; | ||
let lock = false; | ||
@@ -22,2 +23,7 @@ const instance = window.__REDUX_DEVTOOLS_EXTENSION__.connect(options); | ||
const update = store.pipe(skip(1)).subscribe(() => { | ||
if (lock) { | ||
lock = false; | ||
return; | ||
} | ||
options.preAction == null ? void 0 : options.preAction(); | ||
@@ -69,2 +75,15 @@ send({ | ||
} | ||
if (payloadType === 'JUMP_TO_STATE') { | ||
const state = JSON.parse(message.state); | ||
for (const [name, value] of Object.entries(state)) { | ||
var _getStore; | ||
lock = true; | ||
(_getStore = getStore(name)) == null ? void 0 : _getStore.update(() => value); | ||
} | ||
options.postTimelineUpdate == null ? void 0 : options.postTimelineUpdate(); | ||
} | ||
} | ||
@@ -71,0 +90,0 @@ }); |
@@ -13,2 +13,3 @@ (function (global, factory) { | ||
if (!window.__REDUX_DEVTOOLS_EXTENSION__) return; | ||
var lock = false; | ||
@@ -32,2 +33,7 @@ var instance = window.__REDUX_DEVTOOLS_EXTENSION__.connect(options); | ||
if (lock) { | ||
lock = false; | ||
return; | ||
} | ||
(_a = options.preAction) === null || _a === void 0 ? void 0 : _a.call(options); | ||
@@ -71,2 +77,4 @@ send({ | ||
var devtoolsDispose = instance.subscribe(function (message) { | ||
var _a, _b; | ||
if (message.type === 'DISPATCH') { | ||
@@ -79,2 +87,23 @@ var payloadType = message.payload.type; | ||
} | ||
if (payloadType === 'JUMP_TO_STATE') { | ||
var state = JSON.parse(message.state); | ||
var _loop_1 = function _loop_1(name_1, value) { | ||
lock = true; | ||
(_a = elf.getStore(name_1)) === null || _a === void 0 ? void 0 : _a.update(function () { | ||
return value; | ||
}); | ||
}; | ||
for (var _i = 0, _c = Object.entries(state); _i < _c.length; _i++) { | ||
var _d = _c[_i], | ||
name_1 = _d[0], | ||
value = _d[1]; | ||
_loop_1(name_1, value); | ||
} | ||
(_b = options.postTimelineUpdate) === null || _b === void 0 ? void 0 : _b.call(options); | ||
} | ||
} | ||
@@ -81,0 +110,0 @@ }); |
@@ -9,2 +9,3 @@ import { Observable } from 'rxjs'; | ||
name?: string; | ||
postTimelineUpdate?: () => void; | ||
preAction?: () => void; | ||
@@ -27,2 +28,3 @@ actionsDispatcher?: ActionsDispatcher; | ||
}; | ||
state: string; | ||
}) => void): () => void; | ||
@@ -29,0 +31,0 @@ }; |
{ | ||
"name": "@ngneat/elf-devtools", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Redux devtools for elf store", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9016
215