react-native-onyx 3.0.121 → 3.0.123

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
@@ -15,9 +15,6 @@ This method will be deprecated soon. Please use <code>Onyx.connectWithoutView()<
15
15
  <dt><a href="#connectWithoutView">connectWithoutView(connectOptions)</a> ⇒</dt>
16
16
  <dd><p>Connects to an Onyx key given the options passed and listens to its changes.</p>
17
17
  </dd>
18
- <dt><a href="#disconnect">disconnect(connection)</a></dt>
19
- <dd><p>Disconnects and removes the listener from the Onyx key.</p>
20
- </dd>
21
18
  <dt><a href="#set">set(key, value, options)</a></dt>
22
19
  <dd><p>Write a value to our store with the given key</p>
23
20
  </dd>
@@ -91,7 +88,7 @@ Connects to an Onyx key given the options passed and listens to its changes.
91
88
  This method will be deprecated soon. Please use `Onyx.connectWithoutView()` instead.
92
89
 
93
90
  **Kind**: global function
94
- **Returns**: The `Connection` handle to use when calling `Onyx.disconnect()`.
91
+ **Returns**: The `Connection` handle whose `unsubscribe()` stops this subscription.
95
92
 
96
93
  | Param | Description |
97
94
  | --- | --- |
@@ -118,7 +115,7 @@ cache after any same-tick writes have applied.
118
115
  Connects to an Onyx key given the options passed and listens to its changes.
119
116
 
120
117
  **Kind**: global function
121
- **Returns**: The `Connection` handle to use when calling `Onyx.disconnect()`.
118
+ **Returns**: The `Connection` handle whose `unsubscribe()` stops this subscription.
122
119
 
123
120
  | Param | Description |
124
121
  | --- | --- |
@@ -139,26 +136,6 @@ object whenever any member changes; signature `(collection, collectionKey)`.
139
136
  For any other key, the callback fires with the value at that key; signature
140
137
  `(value, key)`. Initial fire is deferred via `scheduleInitialSubscriberNotification` so it reads
141
138
  cache after any same-tick writes have applied.
142
- <a name="disconnect"></a>
143
-
144
- ## disconnect(connection)
145
- Disconnects and removes the listener from the Onyx key.
146
-
147
- **Kind**: global function
148
-
149
- | Param | Description |
150
- | --- | --- |
151
- | connection | Connection object returned by calling `Onyx.connect()` or `Onyx.connectWithoutView()`. |
152
-
153
- **Example**
154
- ```ts
155
- const connection = Onyx.connectWithoutView({
156
- key: ONYXKEYS.SESSION,
157
- callback: onSessionChange,
158
- });
159
-
160
- Onyx.disconnect(connection);
161
- ```
162
139
  <a name="set"></a>
163
140
 
164
141
  ## set(key, value, options)
package/README.md CHANGED
@@ -130,10 +130,10 @@ const connection = Onyx.connectWithoutView({
130
130
  });
131
131
  ```
132
132
 
133
- To teardown the subscription call `Onyx.disconnect()` with the connection returned from `Onyx.connectWithoutView()`. It's recommended to clean up subscriptions anytime you are connecting from within a function to prevent memory leaks.
133
+ To teardown the subscription call `unsubscribe()` on the connection returned from `Onyx.connectWithoutView()`. It's recommended to clean up subscriptions anytime you are connecting from within a function to prevent memory leaks.
134
134
 
135
135
  ```javascript
136
- Onyx.disconnect(connection);
136
+ connection.unsubscribe();
137
137
  ```
138
138
 
139
139
  We can also access values inside React function components via the `useOnyx()` [hook](https://react.dev/reference/react/hooks). When the data changes the component will re-render.
package/dist/Onyx.d.ts CHANGED
@@ -23,7 +23,7 @@ declare function init({ keys, initialKeyStates, evictableKeys, shouldSyncMultipl
23
23
  * @param connectOptions The options object that will define the behavior of the connection.
24
24
  * @param connectOptions.key The Onyx key to subscribe to.
25
25
  * @param connectOptions.callback A function that will be called when the Onyx data we are subscribed changes.
26
- * @returns The `Connection` handle to use when calling `Onyx.disconnect()`.
26
+ * @returns The `Connection` handle whose `unsubscribe()` stops this subscription.
27
27
  */
28
28
  declare function connect<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKey>): Connection;
29
29
  /**
@@ -46,25 +46,9 @@ declare function connect<TKey extends OnyxKey>(connectOptions: ConnectOptions<TK
46
46
  * @param connectOptions The options object that will define the behavior of the connection.
47
47
  * @param connectOptions.key The Onyx key to subscribe to.
48
48
  * @param connectOptions.callback A function that will be called when the Onyx data we are subscribed changes.
49
- * @returns The `Connection` handle to use when calling `Onyx.disconnect()`.
49
+ * @returns The `Connection` handle whose `unsubscribe()` stops this subscription.
50
50
  */
51
51
  declare function connectWithoutView<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKey>): Connection;
52
- /**
53
- * Disconnects and removes the listener from the Onyx key.
54
- *
55
- * @example
56
- * ```ts
57
- * const connection = Onyx.connectWithoutView({
58
- * key: ONYXKEYS.SESSION,
59
- * callback: onSessionChange,
60
- * });
61
- *
62
- * Onyx.disconnect(connection);
63
- * ```
64
- *
65
- * @param connection Connection object returned by calling `Onyx.connect()` or `Onyx.connectWithoutView()`.
66
- */
67
- declare function disconnect(connection: Connection): void;
68
52
  /**
69
53
  * Write a value to our store with the given key
70
54
  *
@@ -208,7 +192,6 @@ declare const Onyx: {
208
192
  };
209
193
  connect: typeof connect;
210
194
  connectWithoutView: typeof connectWithoutView;
211
- disconnect: typeof disconnect;
212
195
  set: typeof set;
213
196
  multiSet: typeof multiSet;
214
197
  merge: typeof merge;
package/dist/Onyx.js CHANGED
@@ -131,7 +131,7 @@ function init({ keys = {}, initialKeyStates = {}, evictableKeys = [], shouldSync
131
131
  * @param connectOptions The options object that will define the behavior of the connection.
132
132
  * @param connectOptions.key The Onyx key to subscribe to.
133
133
  * @param connectOptions.callback A function that will be called when the Onyx data we are subscribed changes.
134
- * @returns The `Connection` handle to use when calling `Onyx.disconnect()`.
134
+ * @returns The `Connection` handle whose `unsubscribe()` stops this subscription.
135
135
  */
136
136
  function connect(connectOptions) {
137
137
  const { key, callback } = connectOptions;
@@ -220,32 +220,11 @@ function connect(connectOptions) {
220
220
  * @param connectOptions The options object that will define the behavior of the connection.
221
221
  * @param connectOptions.key The Onyx key to subscribe to.
222
222
  * @param connectOptions.callback A function that will be called when the Onyx data we are subscribed changes.
223
- * @returns The `Connection` handle to use when calling `Onyx.disconnect()`.
223
+ * @returns The `Connection` handle whose `unsubscribe()` stops this subscription.
224
224
  */
225
225
  function connectWithoutView(connectOptions) {
226
226
  return connect(connectOptions);
227
227
  }
228
- /**
229
- * Disconnects and removes the listener from the Onyx key.
230
- *
231
- * @example
232
- * ```ts
233
- * const connection = Onyx.connectWithoutView({
234
- * key: ONYXKEYS.SESSION,
235
- * callback: onSessionChange,
236
- * });
237
- *
238
- * Onyx.disconnect(connection);
239
- * ```
240
- *
241
- * @param connection Connection object returned by calling `Onyx.connect()` or `Onyx.connectWithoutView()`.
242
- */
243
- function disconnect(connection) {
244
- if (!connection) {
245
- return;
246
- }
247
- connection.unsubscribe();
248
- }
249
228
  /**
250
229
  * Write a value to our store with the given key
251
230
  *
@@ -706,7 +685,6 @@ const Onyx = {
706
685
  METHOD: OnyxUtils_1.default.METHOD,
707
686
  connect,
708
687
  connectWithoutView,
709
- disconnect,
710
688
  set,
711
689
  multiSet,
712
690
  merge,
package/dist/types.d.ts CHANGED
@@ -353,7 +353,7 @@ type MixedOperationsQueue = {
353
353
  };
354
354
  /**
355
355
  * Represents a connection to an Onyx key, returned by `Onyx.connect()`/`Onyx.connectWithoutView()`.
356
- * Pass it to `Onyx.disconnect()` to stop receiving callbacks for this subscription.
356
+ * Call its `unsubscribe()` to stop receiving callbacks for this subscription.
357
357
  */
358
358
  type Connection = {
359
359
  /** Unsubscribe this connection. Idempotent. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "3.0.121",
3
+ "version": "3.0.123",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",