react-native-onyx 1.0.6 → 1.0.9

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 CHANGED
@@ -220,7 +220,7 @@ Insert API responses and lifecycle data into Onyx
220
220
 
221
221
  | Param | Type | Description |
222
222
  | --- | --- | --- |
223
- | data | <code>Array</code> | An array of objects with shape {onyxMethod: oneOf('set', 'merge'), key: string, value: *} |
223
+ | data | <code>Array</code> | An array of objects with shape {onyxMethod: oneOf('set', 'merge', 'mergeCollection'), key: string, value: *} |
224
224
 
225
225
  <a name="init"></a>
226
226
 
@@ -1303,15 +1303,15 @@ function mergeCollection(collectionKey, collection) {
1303
1303
  /**
1304
1304
  * Insert API responses and lifecycle data into Onyx
1305
1305
  *
1306
- * @param {Array} data An array of objects with shape {onyxMethod: oneOf('set', 'merge'), key: string, value: *}
1306
+ * @param {Array} data An array of objects with shape {onyxMethod: oneOf('set', 'merge', 'mergeCollection'), key: string, value: *}
1307
1307
  */
1308
1308
  function update(data) {
1309
1309
  // First, validate the Onyx object is in the format we expect
1310
1310
  _underscore.default.each(data, function (_ref4) {var onyxMethod = _ref4.onyxMethod,key = _ref4.key;
1311
- if (!_underscore.default.contains(['set', 'merge'], onyxMethod)) {
1311
+ if (!_underscore.default.contains(['clear', 'set', 'merge', 'mergecollection'], onyxMethod)) {
1312
1312
  throw new Error("Invalid onyxMethod " + onyxMethod + " in Onyx update.");
1313
1313
  }
1314
- if (!_underscore.default.isString(key)) {
1314
+ if (onyxMethod !== 'clear' && !_underscore.default.isString(key)) {
1315
1315
  throw new Error("Invalid " + typeof key + " key provided in Onyx update. Onyx key must be of type string.");
1316
1316
  }
1317
1317
  });
@@ -1324,6 +1324,12 @@ function update(data) {
1324
1324
  case 'merge':
1325
1325
  merge(key, value);
1326
1326
  break;
1327
+ case 'mergecollection':
1328
+ mergeCollection(key, value);
1329
+ break;
1330
+ case 'clear':
1331
+ clear();
1332
+ break;
1327
1333
  default:
1328
1334
  break;}
1329
1335