react-native-onyx 2.0.136 → 2.0.137

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.
@@ -143,14 +143,14 @@ declare function getCachedCollection<TKey extends CollectionKeyBase>(collectionK
143
143
  /**
144
144
  * When a collection of keys change, search for any callbacks matching the collection key and trigger those callbacks
145
145
  */
146
- declare function keysChanged<TKey extends CollectionKeyBase>(collectionKey: TKey, partialCollection: OnyxCollection<KeyValueMapping[TKey]>, partialPreviousCollection: OnyxCollection<KeyValueMapping[TKey]> | undefined, notifyConnectSubscribers?: boolean, notifyWithOnyxSubscribers?: boolean, notifyUseOnyxHookSubscribers?: boolean): void;
146
+ declare function keysChanged<TKey extends CollectionKeyBase>(collectionKey: TKey, partialCollection: OnyxCollection<KeyValueMapping[TKey]>, partialPreviousCollection: OnyxCollection<KeyValueMapping[TKey]> | undefined, notifyConnectSubscribers?: boolean, notifyWithOnyxSubscribers?: boolean): void;
147
147
  /**
148
148
  * When a key change happens, search for any callbacks matching the key or collection key and trigger those callbacks
149
149
  *
150
150
  * @example
151
151
  * keyChanged(key, value, subscriber => subscriber.initWithStoredValues === false)
152
152
  */
153
- declare function keyChanged<TKey extends OnyxKey>(key: TKey, value: OnyxValue<TKey>, previousValue: OnyxValue<TKey>, canUpdateSubscriber?: (subscriber?: Mapping<OnyxKey>) => boolean, notifyConnectSubscribers?: boolean, notifyWithOnyxSubscribers?: boolean, notifyUseOnyxHookSubscribers?: boolean): void;
153
+ declare function keyChanged<TKey extends OnyxKey>(key: TKey, value: OnyxValue<TKey>, previousValue: OnyxValue<TKey>, canUpdateSubscriber?: (subscriber?: Mapping<OnyxKey>) => boolean, notifyConnectSubscribers?: boolean, notifyWithOnyxSubscribers?: boolean): void;
154
154
  /**
155
155
  * Sends the data obtained from the keys to the connection. It either:
156
156
  * - sets state on the withOnyxInstances
package/dist/OnyxUtils.js CHANGED
@@ -512,7 +512,7 @@ function getCachedCollection(collectionKey, collectionMemberKeys) {
512
512
  /**
513
513
  * When a collection of keys change, search for any callbacks matching the collection key and trigger those callbacks
514
514
  */
515
- function keysChanged(collectionKey, partialCollection, partialPreviousCollection, notifyConnectSubscribers = true, notifyWithOnyxSubscribers = true, notifyUseOnyxHookSubscribers = true) {
515
+ function keysChanged(collectionKey, partialCollection, partialPreviousCollection, notifyConnectSubscribers = true, notifyWithOnyxSubscribers = true) {
516
516
  // We prepare the "cached collection" which is the entire collection + the new partial data that
517
517
  // was merged in via mergeCollection().
518
518
  const cachedCollection = getCachedCollection(collectionKey);
@@ -540,8 +540,7 @@ function keysChanged(collectionKey, partialCollection, partialPreviousCollection
540
540
  const isSubscribedToCollectionMemberKey = isCollectionMemberKey(collectionKey, subscriber.key);
541
541
  // Regular Onyx.connect() subscriber found.
542
542
  if (typeof subscriber.callback === 'function') {
543
- // Check if it's a useOnyx or a regular Onyx.connect() subscriber
544
- if ((subscriber.isUseOnyxSubscriber && !notifyUseOnyxHookSubscribers) || (!subscriber.isUseOnyxSubscriber && !notifyConnectSubscribers)) {
543
+ if (!notifyConnectSubscribers) {
545
544
  continue;
546
545
  }
547
546
  // If they are subscribed to the collection key and using waitForCollectionCallback then we'll
@@ -671,7 +670,7 @@ function keysChanged(collectionKey, partialCollection, partialPreviousCollection
671
670
  * @example
672
671
  * keyChanged(key, value, subscriber => subscriber.initWithStoredValues === false)
673
672
  */
674
- function keyChanged(key, value, previousValue, canUpdateSubscriber = () => true, notifyConnectSubscribers = true, notifyWithOnyxSubscribers = true, notifyUseOnyxHookSubscribers = true) {
673
+ function keyChanged(key, value, previousValue, canUpdateSubscriber = () => true, notifyConnectSubscribers = true, notifyWithOnyxSubscribers = true) {
675
674
  var _a, _b;
676
675
  // Add or remove this key from the recentlyAccessedKeys lists
677
676
  if (value !== null) {
@@ -710,8 +709,7 @@ function keyChanged(key, value, previousValue, canUpdateSubscriber = () => true,
710
709
  }
711
710
  // Subscriber is a regular call to connect() and provided a callback
712
711
  if (typeof subscriber.callback === 'function') {
713
- // Check if it's a useOnyx or a regular Onyx.connect() subscriber
714
- if ((subscriber.isUseOnyxSubscriber && !notifyUseOnyxHookSubscribers) || (!subscriber.isUseOnyxSubscriber && !notifyConnectSubscribers)) {
712
+ if (!notifyConnectSubscribers) {
715
713
  continue;
716
714
  }
717
715
  if (lastConnectionCallbackData.has(subscriber.subscriptionID) && lastConnectionCallbackData.get(subscriber.subscriptionID) === value) {
@@ -891,8 +889,8 @@ function getCollectionDataAndSendAsObject(matchingKeys, mapping) {
891
889
  * scheduleSubscriberUpdate(key, value, subscriber => subscriber.initWithStoredValues === false)
892
890
  */
893
891
  function scheduleSubscriberUpdate(key, value, previousValue, canUpdateSubscriber = () => true) {
894
- const promise = Promise.resolve().then(() => keyChanged(key, value, previousValue, canUpdateSubscriber, true, false, false));
895
- batchUpdates(() => keyChanged(key, value, previousValue, canUpdateSubscriber, false, true, true));
892
+ const promise = Promise.resolve().then(() => keyChanged(key, value, previousValue, canUpdateSubscriber, true, false));
893
+ batchUpdates(() => keyChanged(key, value, previousValue, canUpdateSubscriber, false, true));
896
894
  return Promise.all([maybeFlushBatchUpdates(), promise]).then(() => undefined);
897
895
  }
898
896
  /**
@@ -901,8 +899,8 @@ function scheduleSubscriberUpdate(key, value, previousValue, canUpdateSubscriber
901
899
  * subscriber callbacks receive the data in a different format than they normally expect and it breaks code.
902
900
  */
903
901
  function scheduleNotifyCollectionSubscribers(key, value, previousValue) {
904
- const promise = Promise.resolve().then(() => keysChanged(key, value, previousValue, true, false, false));
905
- batchUpdates(() => keysChanged(key, value, previousValue, false, true, true));
902
+ const promise = Promise.resolve().then(() => keysChanged(key, value, previousValue, true, false));
903
+ batchUpdates(() => keysChanged(key, value, previousValue, false, true));
906
904
  return Promise.all([maybeFlushBatchUpdates(), promise]).then(() => undefined);
907
905
  }
908
906
  /**
package/dist/types.d.ts CHANGED
@@ -235,8 +235,6 @@ type BaseConnectOptions = {
235
235
  * with the same connect configurations.
236
236
  */
237
237
  reuseConnection?: boolean;
238
- /** Indicates whether this subscriber is created from the useOnyx hook. */
239
- isUseOnyxSubscriber?: boolean;
240
238
  };
241
239
  /** Represents the callback function used in `Onyx.connect()` method with a regular key. */
242
240
  type DefaultConnectCallback<TKey extends OnyxKey> = (value: OnyxEntry<KeyValueMapping[TKey]>, key: TKey) => void;
package/dist/useOnyx.js CHANGED
@@ -276,7 +276,6 @@ function useOnyx(key, options, dependencies = []) {
276
276
  initWithStoredValues: options === null || options === void 0 ? void 0 : options.initWithStoredValues,
277
277
  waitForCollectionCallback: OnyxUtils_1.default.isCollectionKey(key),
278
278
  reuseConnection: options === null || options === void 0 ? void 0 : options.reuseConnection,
279
- isUseOnyxSubscriber: true,
280
279
  });
281
280
  checkEvictableKey();
282
281
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "2.0.136",
3
+ "version": "2.0.137",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",