@exodus/atoms 5.7.0 → 5.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/atoms",
3
- "version": "5.7.0",
3
+ "version": "5.7.1",
4
4
  "main": "src/index.js",
5
5
  "description": "Abstraction for encapsulating a piece of data behind a simple unified interface: get, set, observe",
6
6
  "author": "Exodus Movement Inc.",
@@ -36,5 +36,5 @@
36
36
  "eslint": "^8.44.0",
37
37
  "jest": "^29.1.2"
38
38
  },
39
- "gitHead": "d6c6919e0879a84f30a6fa5c2f2e0d9a35ce7d2f"
39
+ "gitHead": "ac180dfc636ccb393938aefa88e3824471646f8b"
40
40
  }
@@ -26,6 +26,7 @@ const enforceObservableRules = ({ defaultValue, getInitialized = () => true, log
26
26
 
27
27
  const observe = (listener) => {
28
28
  let called = false
29
+ let valueEmittedFromGet
29
30
  listener = withChangeDetection(listener)
30
31
 
31
32
  const publishSerially = (value) => {
@@ -35,8 +36,20 @@ const enforceObservableRules = ({ defaultValue, getInitialized = () => true, log
35
36
 
36
37
  // note: call observe() first to give it a chance to throw if it's not supported
37
38
  // if the subscription already fired once, ignore first get
38
- get().then((value) => !called && publishSerially(value))
39
- return atom.observe((value) => publishSerially(postProcessValue(value)))
39
+ get().then((value) => {
40
+ if (!called) {
41
+ valueEmittedFromGet = value
42
+ publishSerially(value)
43
+ }
44
+ })
45
+ return atom.observe((value) => {
46
+ if (valueEmittedFromGet && value === valueEmittedFromGet) {
47
+ valueEmittedFromGet = undefined // ignore changes from observe only for first call
48
+ return
49
+ }
50
+
51
+ return publishSerially(postProcessValue(value))
52
+ })
40
53
  }
41
54
 
42
55
  const set = makeConcurrent(async (value) => {