@exodus/atoms 3.0.0 → 3.1.0

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/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # `@exodus/atoms`
2
2
 
3
- Module to store and manage wallet accounts instances.
4
-
5
3
  ## Install
6
4
 
7
5
  ```sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/atoms",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "main": "src/index.js",
5
5
  "author": "Exodus Movement Inc.",
6
6
  "scripts": {
@@ -33,5 +33,5 @@
33
33
  "eslint": "^8.33.0",
34
34
  "jest": "^29.1.2"
35
35
  },
36
- "gitHead": "09eebd39041cf2dda35741828ec8e574f374f4f2"
36
+ "gitHead": "6aca43c9d371da13ffca0de1d9a0bc9c3f14ee25"
37
37
  }
@@ -5,16 +5,30 @@ import enforceObservableRules from '../enforce-rules'
5
5
 
6
6
  const createRemoteConfigAtomFactory =
7
7
  ({ remoteConfig }) =>
8
- ({ path, defaultValue }) => {
8
+ ({ path, selector, defaultValue }) => {
9
+ if (path && selector) {
10
+ throw new Error(
11
+ 'Provide either a path or a selector to get data from remote config - not both.'
12
+ )
13
+ }
14
+
15
+ const getValue = (value) => (selector ? selector(value) : getValueAtPath(value, path))
16
+
9
17
  const { notify, observe } = createSimpleObserver()
10
18
 
11
- const get = () => remoteConfig.get(path)
19
+ const get = async () => {
20
+ const data = await remoteConfig.getAll()
21
+ return getValue(data)
22
+ }
12
23
 
13
24
  const set = async () => {
14
25
  throw new Error('remoteConfig is read-only')
15
26
  }
16
27
 
17
- remoteConfig.on('sync', ({ current }) => notify(getValueAtPath(current, path)))
28
+ remoteConfig.on('sync', async ({ current }) => {
29
+ const data = getValue(current)
30
+ return notify(data)
31
+ })
18
32
 
19
33
  return enforceObservableRules({
20
34
  get,