@exodus/atoms
Advanced tools
Comparing version 7.0.2 to 7.0.3
@@ -6,2 +6,6 @@ # Change Log | ||
## [7.0.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@7.0.2...@exodus/atoms@7.0.3) (2024-02-21) | ||
**Note:** Version bump only for package @exodus/atoms | ||
## [7.0.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@7.0.1...@exodus/atoms@7.0.2) (2024-02-08) | ||
@@ -8,0 +12,0 @@ |
const createAtomObserver = ({ port, atom, event, immediateRegister = true }) => { | ||
let emitting = false; | ||
let unobserve; | ||
let lastMessage = -1; | ||
const register = () => { | ||
@@ -8,4 +9,6 @@ if (unobserve) | ||
unobserve = atom.observe((value) => { | ||
if (emitting) | ||
if (emitting) { | ||
port.emit(event, value); | ||
lastMessage = Date.now(); | ||
} | ||
}); | ||
@@ -15,6 +18,10 @@ }; | ||
unobserve?.(); | ||
unobserve = undefined; | ||
emitting = false; | ||
}; | ||
const start = async () => { | ||
emitting = true; | ||
port.emit(event, await atom.get()); | ||
const startTime = Date.now(); | ||
if (startTime > lastMessage) | ||
port.emit(event, await atom.get()); | ||
}; | ||
@@ -21,0 +28,0 @@ if (immediateRegister) { |
{ | ||
"name": "@exodus/atoms", | ||
"version": "7.0.2", | ||
"version": "7.0.3", | ||
"main": "lib/index.js", | ||
@@ -48,3 +48,3 @@ "description": "Abstraction for encapsulating a piece of data behind a simple unified interface: get, set, observe", | ||
}, | ||
"gitHead": "6577648863b930c44d19836203dc573146e5bbfd" | ||
"gitHead": "0c9997d2bcfef2a557eff5a8fbaccb5d16ade56d" | ||
} |
58859
947