react-native-onyx 1.0.30 → 1.0.32
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/API.md +30 -5
- package/dist/web.development.js +4331 -3017
- package/dist/web.development.js.map +1 -1
- package/dist/web.min.js +2 -1
- package/dist/web.min.js.LICENSE.txt +9 -0
- package/dist/web.min.js.map +1 -1
- package/lib/Onyx.js +52 -8
- package/lib/storage/NativeStorage.js +2 -2
- package/lib/storage/providers/SQLiteStorage.js +118 -0
- package/lib/storage/providers/__mocks__/SQLiteStorage.js +3 -0
- package/package.json +22 -10
package/API.md
CHANGED
|
@@ -27,6 +27,11 @@ For this reason, Onyx works more similar to what you might expect from a native
|
|
|
27
27
|
available async. Since we have code in our main applications that might expect things to work this way it's not safe to change this
|
|
28
28
|
behavior just yet.</p>
|
|
29
29
|
</dd>
|
|
30
|
+
<dt><a href="#notifyCollectionSubscribersOnNextTick">notifyCollectionSubscribersOnNextTick(key, value)</a></dt>
|
|
31
|
+
<dd><p>This method is similar to notifySubscribersOnNextTick but it is built for working specifically with collections
|
|
32
|
+
so that keysChanged() is triggered for the collection and not keyChanged(). If this was not done, then the
|
|
33
|
+
subscriber callbacks receive the data in a different format than they normally expect and it breaks code.</p>
|
|
34
|
+
</dd>
|
|
30
35
|
<dt><a href="#set">set(key, value)</a> ⇒ <code>Promise</code></dt>
|
|
31
36
|
<dd><p>Write a value to our store with the given key</p>
|
|
32
37
|
</dd>
|
|
@@ -43,7 +48,7 @@ concatenate. See here: <a href="https://github.com/lodash/lodash/issues/2872">ht
|
|
|
43
48
|
applied in the order they were called. Note: <code>Onyx.set()</code> calls do not work this way so use caution when mixing
|
|
44
49
|
<code>Onyx.merge()</code> and <code>Onyx.set()</code>.</p>
|
|
45
50
|
</dd>
|
|
46
|
-
<dt><a href="#clear">clear()</a> ⇒ <code>Promise.<void></code></dt>
|
|
51
|
+
<dt><a href="#clear">clear(keysToPreserve)</a> ⇒ <code>Promise.<void></code></dt>
|
|
47
52
|
<dd><p>Clear out all the data in the store</p>
|
|
48
53
|
<p>Note that calling Onyx.clear() and then Onyx.set() on a key with a default
|
|
49
54
|
key state may store an unexpected value in Storage.</p>
|
|
@@ -62,7 +67,7 @@ value will be saved to storage after the default value.</p>
|
|
|
62
67
|
<dt><a href="#mergeCollection">mergeCollection(collectionKey, collection)</a> ⇒ <code>Promise</code></dt>
|
|
63
68
|
<dd><p>Merges a collection based on their keys</p>
|
|
64
69
|
</dd>
|
|
65
|
-
<dt><a href="#update">update(data)</a></dt>
|
|
70
|
+
<dt><a href="#update">update(data)</a> ⇒ <code>Promise</code></dt>
|
|
66
71
|
<dd><p>Insert API responses and lifecycle data into Onyx</p>
|
|
67
72
|
</dd>
|
|
68
73
|
<dt><a href="#init">init([options])</a></dt>
|
|
@@ -123,7 +128,7 @@ Subscribes a react component's state directly to a store key
|
|
|
123
128
|
| [mapping.callback] | <code>function</code> | a method that will be called with changed data This is used by any non-React code to connect to Onyx |
|
|
124
129
|
| [mapping.initWithStoredValues] | <code>Boolean</code> | If set to false, then no data will be prefilled into the component |
|
|
125
130
|
| [mapping.waitForCollectionCallback] | <code>Boolean</code> | If set to true, it will return the entire collection to the callback as a single object |
|
|
126
|
-
| [mapping.selector] | <code>String</code> \| <code>function</code> | THIS PARAM IS ONLY USED WITH withOnyx(). If included, this will be used to subscribe to a subset of an Onyx key's data.
|
|
131
|
+
| [mapping.selector] | <code>String</code> \| <code>function</code> | THIS PARAM IS ONLY USED WITH withOnyx(). If included, this will be used to subscribe to a subset of an Onyx key's data. If the selector is a string, the selector is passed to lodashGet on the sourceData. If the selector is a function, the sourceData is passed to the selector and should return the simplified data. Using this setting on `withOnyx` can have very positive performance benefits because the component will only re-render when the subset of data changes. Otherwise, any change of data on any property would normally cause the component to re-render (and that can be expensive from a performance standpoint). |
|
|
127
132
|
|
|
128
133
|
**Example**
|
|
129
134
|
```js
|
|
@@ -168,6 +173,20 @@ behavior just yet.
|
|
|
168
173
|
```js
|
|
169
174
|
notifySubscribersOnNextTick(key, value, subscriber => subscriber.initWithStoredValues === false)
|
|
170
175
|
```
|
|
176
|
+
<a name="notifyCollectionSubscribersOnNextTick"></a>
|
|
177
|
+
|
|
178
|
+
## notifyCollectionSubscribersOnNextTick(key, value)
|
|
179
|
+
This method is similar to notifySubscribersOnNextTick but it is built for working specifically with collections
|
|
180
|
+
so that keysChanged() is triggered for the collection and not keyChanged(). If this was not done, then the
|
|
181
|
+
subscriber callbacks receive the data in a different format than they normally expect and it breaks code.
|
|
182
|
+
|
|
183
|
+
**Kind**: global function
|
|
184
|
+
|
|
185
|
+
| Param | Type |
|
|
186
|
+
| --- | --- |
|
|
187
|
+
| key | <code>String</code> |
|
|
188
|
+
| value | <code>\*</code> |
|
|
189
|
+
|
|
171
190
|
<a name="set"></a>
|
|
172
191
|
|
|
173
192
|
## set(key, value) ⇒ <code>Promise</code>
|
|
@@ -225,7 +244,7 @@ Onyx.merge(ONYXKEYS.POLICY, {name: 'My Workspace'}); // -> {id: 1, name: 'My Wor
|
|
|
225
244
|
```
|
|
226
245
|
<a name="clear"></a>
|
|
227
246
|
|
|
228
|
-
## clear() ⇒ <code>Promise.<void></code>
|
|
247
|
+
## clear(keysToPreserve) ⇒ <code>Promise.<void></code>
|
|
229
248
|
Clear out all the data in the store
|
|
230
249
|
|
|
231
250
|
Note that calling Onyx.clear() and then Onyx.set() on a key with a default
|
|
@@ -245,6 +264,11 @@ Storage.setItem() from Onyx.clear() will have already finished and the merged
|
|
|
245
264
|
value will be saved to storage after the default value.
|
|
246
265
|
|
|
247
266
|
**Kind**: global function
|
|
267
|
+
|
|
268
|
+
| Param | Type | Description |
|
|
269
|
+
| --- | --- | --- |
|
|
270
|
+
| keysToPreserve | <code>Array</code> | is a list of ONYXKEYS that should not be cleared with the rest of the data |
|
|
271
|
+
|
|
248
272
|
<a name="mergeCollection"></a>
|
|
249
273
|
|
|
250
274
|
## mergeCollection(collectionKey, collection) ⇒ <code>Promise</code>
|
|
@@ -266,10 +290,11 @@ Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, {
|
|
|
266
290
|
```
|
|
267
291
|
<a name="update"></a>
|
|
268
292
|
|
|
269
|
-
## update(data)
|
|
293
|
+
## update(data) ⇒ <code>Promise</code>
|
|
270
294
|
Insert API responses and lifecycle data into Onyx
|
|
271
295
|
|
|
272
296
|
**Kind**: global function
|
|
297
|
+
**Returns**: <code>Promise</code> - resolves when all operations are complete
|
|
273
298
|
|
|
274
299
|
| Param | Type | Description |
|
|
275
300
|
| --- | --- | --- |
|