2626<dt ><a href =" #initStoreValues " >initStoreValues(keys, initialKeyStates, evictableKeys)</a ></dt >
2727<dd ><p >Sets the initial values for the Onyx store</p >
2828</dd >
29- <dt ><a href =" #maybeFlushBatchUpdates " >maybeFlushBatchUpdates()</a ></dt >
30- <dd ><p >We are batching together onyx updates. This helps with use cases where we schedule onyx updates after each other.
31- This happens for example in the Onyx.update function, where we process API responses that might contain a lot of
32- update operations. Instead of calling the subscribers for each update operation, we batch them together which will
33- cause react to schedule the updates at once instead of after each other. This is mainly a performance optimization.</p >
34- </dd >
3529<dt ><a href =" #reduceCollectionWithSelector " >reduceCollectionWithSelector()</a ></dt >
3630<dd ><p >Takes a collection of items (eg. {testKey_1:{a:' ; a' ; }, testKey_2:{b:' ; b' ; }})
3731and runs it through a reducer function to return a subset of the data according to a selector.
@@ -61,6 +55,9 @@ to the values for those keys (correctly typed) such as <code>[OnyxCollection<
6155<dd ><p >Checks to see if the subscriber' ; s supplied key
6256is associated with a collection of keys.</p >
6357</dd >
58+ <dt ><a href =" #isCollectionMember " >isCollectionMember(key)</a > ⇒</dt >
59+ <dd ><p >Checks if a given key is a collection member key (not just a collection key).</p >
60+ </dd >
6461<dt ><a href =" #splitCollectionMemberKey " >splitCollectionMemberKey(key, collectionKey)</a > ⇒</dt >
6562<dd ><p >Splits a collection member key into the collection key part and the ID part.</p >
6663</dd >
@@ -98,11 +95,14 @@ run out of storage the least recently accessed key can be removed.</p>
9895<dt ><a href =" #getCollectionDataAndSendAsObject " >getCollectionDataAndSendAsObject()</a ></dt >
9996<dd ><p >Gets the data for a given an array of matching keys, combines them into an object, and sends the result back to the subscriber.</p >
10097</dd >
98+ <dt ><a href =" #prepareSubscriberUpdate " >prepareSubscriberUpdate(callback)</a ></dt >
99+ <dd ><p >Delays promise resolution until the next macrotask to prevent race condition if the key subscription is in progress.</p >
100+ </dd >
101101<dt ><a href =" #scheduleSubscriberUpdate " >scheduleSubscriberUpdate()</a ></dt >
102102<dd ><p >Schedules an update that will be appended to the macro task queue (so it doesn' ; t update the subscribers immediately).</p >
103103</dd >
104104<dt ><a href =" #scheduleNotifyCollectionSubscribers " >scheduleNotifyCollectionSubscribers()</a ></dt >
105- <dd ><p >This method is similar to notifySubscribersOnNextTick but it is built for working specifically with collections
105+ <dd ><p >This method is similar to scheduleSubscriberUpdate but it is built for working specifically with collections
106106so that keysChanged() is triggered for the collection and not keyChanged(). If this was not done, then the
107107subscriber callbacks receive the data in a different format than they normally expect and it breaks code.</p >
108108</dd >
@@ -230,15 +230,6 @@ Sets the initial values for the Onyx store
230230| initialKeyStates | initial data to set when ` init() ` and ` clear() ` are called |
231231| evictableKeys | This is an array of keys (individual or collection patterns) that when provided to Onyx are flagged as "safe" for removal. |
232232
233- <a name =" maybeFlushBatchUpdates " ></a >
234-
235- ## maybeFlushBatchUpdates()
236- We are batching together onyx updates. This helps with use cases where we schedule onyx updates after each other.
237- This happens for example in the Onyx.update function, where we process API responses that might contain a lot of
238- update operations. Instead of calling the subscribers for each update operation, we batch them together which will
239- cause react to schedule the updates at once instead of after each other. This is mainly a performance optimization.
240-
241- ** Kind** : global function
242233<a name =" reduceCollectionWithSelector " ></a >
243234
244235## reduceCollectionWithSelector()
@@ -304,6 +295,18 @@ Checks to see if the subscriber's supplied key
304295is associated with a collection of keys.
305296
306297** Kind** : global function
298+ <a name =" isCollectionMember " ></a >
299+
300+ ## isCollectionMember(key) ⇒
301+ Checks if a given key is a collection member key (not just a collection key).
302+
303+ ** Kind** : global function
304+ ** Returns** : true if the key is a collection member, false otherwise
305+
306+ | Param | Description |
307+ | --- | --- |
308+ | key | The key to check |
309+
307310<a name =" splitCollectionMemberKey " ></a >
308311
309312## splitCollectionMemberKey(key, collectionKey) ⇒
@@ -402,6 +405,17 @@ run out of storage the least recently accessed key can be removed.
402405Gets the data for a given an array of matching keys, combines them into an object, and sends the result back to the subscriber.
403406
404407** Kind** : global function
408+ <a name =" prepareSubscriberUpdate " ></a >
409+
410+ ## prepareSubscriberUpdate(callback)
411+ Delays promise resolution until the next macrotask to prevent race condition if the key subscription is in progress.
412+
413+ ** Kind** : global function
414+
415+ | Param | Description |
416+ | --- | --- |
417+ | callback | The keyChanged/keysChanged callback |
418+
405419<a name =" scheduleSubscriberUpdate " ></a >
406420
407421## scheduleSubscriberUpdate()
@@ -415,7 +429,7 @@ scheduleSubscriberUpdate(key, value, subscriber => subscriber.initWithStoredValu
415429<a name =" scheduleNotifyCollectionSubscribers " ></a >
416430
417431## scheduleNotifyCollectionSubscribers()
418- This method is similar to notifySubscribersOnNextTick but it is built for working specifically with collections
432+ This method is similar to scheduleSubscriberUpdate but it is built for working specifically with collections
419433so that keysChanged() is triggered for the collection and not keyChanged(). If this was not done, then the
420434subscriber callbacks receive the data in a different format than they normally expect and it breaks code.
421435
0 commit comments