@exodus/atoms 2.8.0 → 2.9.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 +2 -2
- package/src/enhancers/block-until.js +31 -0
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/atoms",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"scripts": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"delay": "^5.0.0",
|
|
32
32
|
"jest": "^29.1.2"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "4c0fd59736ac29113f8b87c89ad3e8e87615b21b"
|
|
35
35
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import enforceObservableRules from '../enforce-rules'
|
|
2
|
+
|
|
3
|
+
export default function blockUntil({ atom, unblock }) {
|
|
4
|
+
const get = async () => unblock().then(atom.get)
|
|
5
|
+
|
|
6
|
+
const { observe, ...rest } = enforceObservableRules({
|
|
7
|
+
...atom,
|
|
8
|
+
get,
|
|
9
|
+
set: atom.set,
|
|
10
|
+
observe: atom.observe,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
...rest,
|
|
15
|
+
observe: (callback) => {
|
|
16
|
+
let isSubscribed = true
|
|
17
|
+
let unsubscribe = () => {}
|
|
18
|
+
|
|
19
|
+
unblock().then(() => {
|
|
20
|
+
if (isSubscribed) {
|
|
21
|
+
unsubscribe = atom.observe(callback)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
isSubscribed = false
|
|
27
|
+
unsubscribe()
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { default as createEnabledAssetsAtom } from './factories/enabled-assets'
|
|
|
8
8
|
export { default as createDisabledAssetsAtom } from './factories/disabled-assets'
|
|
9
9
|
export { default as fromEventEmitter } from './event-emitter'
|
|
10
10
|
export { default as compute } from './enhancers/compute'
|
|
11
|
+
export { default as blockUntil } from './enhancers/block-until'
|
|
11
12
|
export { default as difference } from './enhancers/difference'
|
|
12
13
|
export { default as withSerialization } from './enhancers/with-serialization'
|
|
13
14
|
export { default as combine } from './enhancers/combine'
|