@exodus/atoms
Advanced tools
Comparing version 5.7.0 to 5.7.1
{ | ||
"name": "@exodus/atoms", | ||
"version": "5.7.0", | ||
"version": "5.7.1", | ||
"main": "src/index.js", | ||
@@ -39,3 +39,3 @@ "description": "Abstraction for encapsulating a piece of data behind a simple unified interface: get, set, observe", | ||
}, | ||
"gitHead": "d6c6919e0879a84f30a6fa5c2f2e0d9a35ce7d2f" | ||
"gitHead": "ac180dfc636ccb393938aefa88e3824471646f8b" | ||
} |
@@ -29,2 +29,3 @@ import makeConcurrent from 'make-concurrent' | ||
let called = false | ||
let valueEmittedFromGet | ||
listener = withChangeDetection(listener) | ||
@@ -39,4 +40,16 @@ | ||
// if the subscription already fired once, ignore first get | ||
get().then((value) => !called && publishSerially(value)) | ||
return atom.observe((value) => publishSerially(postProcessValue(value))) | ||
get().then((value) => { | ||
if (!called) { | ||
valueEmittedFromGet = value | ||
publishSerially(value) | ||
} | ||
}) | ||
return atom.observe((value) => { | ||
if (valueEmittedFromGet && value === valueEmittedFromGet) { | ||
valueEmittedFromGet = undefined // ignore changes from observe only for first call | ||
return | ||
} | ||
return publishSerially(postProcessValue(value)) | ||
}) | ||
} | ||
@@ -43,0 +56,0 @@ |
23395
694