react-native-onyx 2.0.122 → 2.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
@@ -9,12 +9,16 @@
9
9
  <dd><p>Initialize the store with actions and listening for storage events</p>
10
10
  </dd>
11
11
  <dt><a href="#connect">connect(connectOptions)</a> ⇒</dt>
12
+ <dd><p>Connects to an Onyx key given the options passed and listens to its changes.
13
+ This method will be deprecated soon. Please use <code>Onyx.connectWithoutView()</code> instead.</p>
14
+ </dd>
15
+ <dt><a href="#connectWithoutView">connectWithoutView(connectOptions)</a> ⇒</dt>
12
16
  <dd><p>Connects to an Onyx key given the options passed and listens to its changes.</p>
13
17
  </dd>
14
18
  <dt><a href="#disconnect">disconnect(connection)</a></dt>
15
19
  <dd><p>Disconnects and removes the listener from the Onyx key.</p>
16
20
  </dd>
17
- <dt><a href="#set">set(key, value)</a></dt>
21
+ <dt><a href="#set">set(key, value, options)</a></dt>
18
22
  <dd><p>Write a value to our store with the given key</p>
19
23
  </dd>
20
24
  <dt><a href="#multiSet">multiSet(data)</a></dt>
@@ -66,6 +70,33 @@ Initialize the store with actions and listening for storage events
66
70
 
67
71
  ## connect(connectOptions) ⇒
68
72
  Connects to an Onyx key given the options passed and listens to its changes.
73
+ This method will be deprecated soon. Please use `Onyx.connectWithoutView()` instead.
74
+
75
+ **Kind**: global function
76
+ **Returns**: The connection object to use when calling `Onyx.disconnect()`.
77
+
78
+ | Param | Description |
79
+ | --- | --- |
80
+ | connectOptions | The options object that will define the behavior of the connection. |
81
+ | connectOptions.key | The Onyx key to subscribe to. |
82
+ | connectOptions.callback | A function that will be called when the Onyx data we are subscribed changes. |
83
+ | connectOptions.waitForCollectionCallback | If set to `true`, it will return the entire collection to the callback as a single object. |
84
+ | connectOptions.withOnyxInstance | The `withOnyx` class instance to be internally passed. **Only used inside `withOnyx()` HOC.** |
85
+ | connectOptions.statePropertyName | The name of the component's prop that is connected to the Onyx key. **Only used inside `withOnyx()` HOC.** |
86
+ | connectOptions.displayName | The component's display name. **Only used inside `withOnyx()` HOC.** |
87
+ | connectOptions.selector | This will be used to subscribe to a subset of an Onyx key's data. **Only used inside `useOnyx()` hook or `withOnyx()` HOC.** Using this setting on `useOnyx()` or `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). |
88
+
89
+ **Example**
90
+ ```ts
91
+ const connection = Onyx.connectWithoutView({
92
+ key: ONYXKEYS.SESSION,
93
+ callback: onSessionChange,
94
+ });
95
+ ```
96
+ <a name="connectWithoutView"></a>
97
+
98
+ ## connectWithoutView(connectOptions) ⇒
99
+ Connects to an Onyx key given the options passed and listens to its changes.
69
100
 
70
101
  **Kind**: global function
71
102
  **Returns**: The connection object to use when calling `Onyx.disconnect()`.
@@ -83,7 +114,7 @@ Connects to an Onyx key given the options passed and listens to its changes.
83
114
 
84
115
  **Example**
85
116
  ```ts
86
- const connection = Onyx.connect({
117
+ const connection = Onyx.connectWithoutView({
87
118
  key: ONYXKEYS.SESSION,
88
119
  callback: onSessionChange,
89
120
  });
@@ -97,11 +128,11 @@ Disconnects and removes the listener from the Onyx key.
97
128
 
98
129
  | Param | Description |
99
130
  | --- | --- |
100
- | connection | Connection object returned by calling `Onyx.connect()`. |
131
+ | connection | Connection object returned by calling `Onyx.connect()` or `Onyx.connectWithoutView()`. |
101
132
 
102
133
  **Example**
103
134
  ```ts
104
- const connection = Onyx.connect({
135
+ const connection = Onyx.connectWithoutView({
105
136
  key: ONYXKEYS.SESSION,
106
137
  callback: onSessionChange,
107
138
  });
@@ -110,7 +141,7 @@ Onyx.disconnect(connection);
110
141
  ```
111
142
  <a name="set"></a>
112
143
 
113
- ## set(key, value)
144
+ ## set(key, value, options)
114
145
  Write a value to our store with the given key
115
146
 
116
147
  **Kind**: global function
@@ -119,6 +150,7 @@ Write a value to our store with the given key
119
150
  | --- | --- |
120
151
  | key | ONYXKEY to set |
121
152
  | value | value to store |
153
+ | options | optional configuration object |
122
154
 
123
155
  <a name="multiSet"></a>
124
156
 
package/dist/Onyx.d.ts CHANGED
@@ -5,10 +5,11 @@ import type { Connection } from './OnyxConnectionManager';
5
5
  declare function init({ keys, initialKeyStates, evictableKeys, maxCachedKeysCount, shouldSyncMultipleInstances, debugSetState, enablePerformanceMetrics, skippableCollectionMemberIDs, fullyMergedSnapshotKeys, }: InitOptions): void;
6
6
  /**
7
7
  * Connects to an Onyx key given the options passed and listens to its changes.
8
+ * This method will be deprecated soon. Please use `Onyx.connectWithoutView()` instead.
8
9
  *
9
10
  * @example
10
11
  * ```ts
11
- * const connection = Onyx.connect({
12
+ * const connection = Onyx.connectWithoutView({
12
13
  * key: ONYXKEYS.SESSION,
13
14
  * callback: onSessionChange,
14
15
  * });
@@ -28,12 +29,37 @@ declare function init({ keys, initialKeyStates, evictableKeys, maxCachedKeysCoun
28
29
  * @returns The connection object to use when calling `Onyx.disconnect()`.
29
30
  */
30
31
  declare function connect<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKey>): Connection;
32
+ /**
33
+ * Connects to an Onyx key given the options passed and listens to its changes.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const connection = Onyx.connectWithoutView({
38
+ * key: ONYXKEYS.SESSION,
39
+ * callback: onSessionChange,
40
+ * });
41
+ * ```
42
+ *
43
+ * @param connectOptions The options object that will define the behavior of the connection.
44
+ * @param connectOptions.key The Onyx key to subscribe to.
45
+ * @param connectOptions.callback A function that will be called when the Onyx data we are subscribed changes.
46
+ * @param connectOptions.waitForCollectionCallback If set to `true`, it will return the entire collection to the callback as a single object.
47
+ * @param connectOptions.withOnyxInstance The `withOnyx` class instance to be internally passed. **Only used inside `withOnyx()` HOC.**
48
+ * @param connectOptions.statePropertyName The name of the component's prop that is connected to the Onyx key. **Only used inside `withOnyx()` HOC.**
49
+ * @param connectOptions.displayName The component's display name. **Only used inside `withOnyx()` HOC.**
50
+ * @param connectOptions.selector This will be used to subscribe to a subset of an Onyx key's data. **Only used inside `useOnyx()` hook or `withOnyx()` HOC.**
51
+ * Using this setting on `useOnyx()` or `withOnyx()` can have very positive performance benefits because the component will only re-render
52
+ * when the subset of data changes. Otherwise, any change of data on any property would normally
53
+ * cause the component to re-render (and that can be expensive from a performance standpoint).
54
+ * @returns The connection object to use when calling `Onyx.disconnect()`.
55
+ */
56
+ declare function connectWithoutView<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKey>): Connection;
31
57
  /**
32
58
  * Disconnects and removes the listener from the Onyx key.
33
59
  *
34
60
  * @example
35
61
  * ```ts
36
- * const connection = Onyx.connect({
62
+ * const connection = Onyx.connectWithoutView({
37
63
  * key: ONYXKEYS.SESSION,
38
64
  * callback: onSessionChange,
39
65
  * });
@@ -41,7 +67,7 @@ declare function connect<TKey extends OnyxKey>(connectOptions: ConnectOptions<TK
41
67
  * Onyx.disconnect(connection);
42
68
  * ```
43
69
  *
44
- * @param connection Connection object returned by calling `Onyx.connect()`.
70
+ * @param connection Connection object returned by calling `Onyx.connect()` or `Onyx.connectWithoutView()`.
45
71
  */
46
72
  declare function disconnect(connection: Connection): void;
47
73
  /**
@@ -144,6 +170,7 @@ declare const Onyx: {
144
170
  readonly CLEAR: "clear";
145
171
  };
146
172
  connect: typeof connect;
173
+ connectWithoutView: typeof connectWithoutView;
147
174
  disconnect: typeof disconnect;
148
175
  set: typeof set;
149
176
  multiSet: typeof multiSet;
package/dist/Onyx.js CHANGED
@@ -66,10 +66,11 @@ function init({ keys = {}, initialKeyStates = {}, evictableKeys = [], maxCachedK
66
66
  }
67
67
  /**
68
68
  * Connects to an Onyx key given the options passed and listens to its changes.
69
+ * This method will be deprecated soon. Please use `Onyx.connectWithoutView()` instead.
69
70
  *
70
71
  * @example
71
72
  * ```ts
72
- * const connection = Onyx.connect({
73
+ * const connection = Onyx.connectWithoutView({
73
74
  * key: ONYXKEYS.SESSION,
74
75
  * callback: onSessionChange,
75
76
  * });
@@ -91,12 +92,39 @@ function init({ keys = {}, initialKeyStates = {}, evictableKeys = [], maxCachedK
91
92
  function connect(connectOptions) {
92
93
  return OnyxConnectionManager_1.default.connect(connectOptions);
93
94
  }
95
+ /**
96
+ * Connects to an Onyx key given the options passed and listens to its changes.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const connection = Onyx.connectWithoutView({
101
+ * key: ONYXKEYS.SESSION,
102
+ * callback: onSessionChange,
103
+ * });
104
+ * ```
105
+ *
106
+ * @param connectOptions The options object that will define the behavior of the connection.
107
+ * @param connectOptions.key The Onyx key to subscribe to.
108
+ * @param connectOptions.callback A function that will be called when the Onyx data we are subscribed changes.
109
+ * @param connectOptions.waitForCollectionCallback If set to `true`, it will return the entire collection to the callback as a single object.
110
+ * @param connectOptions.withOnyxInstance The `withOnyx` class instance to be internally passed. **Only used inside `withOnyx()` HOC.**
111
+ * @param connectOptions.statePropertyName The name of the component's prop that is connected to the Onyx key. **Only used inside `withOnyx()` HOC.**
112
+ * @param connectOptions.displayName The component's display name. **Only used inside `withOnyx()` HOC.**
113
+ * @param connectOptions.selector This will be used to subscribe to a subset of an Onyx key's data. **Only used inside `useOnyx()` hook or `withOnyx()` HOC.**
114
+ * Using this setting on `useOnyx()` or `withOnyx()` can have very positive performance benefits because the component will only re-render
115
+ * when the subset of data changes. Otherwise, any change of data on any property would normally
116
+ * cause the component to re-render (and that can be expensive from a performance standpoint).
117
+ * @returns The connection object to use when calling `Onyx.disconnect()`.
118
+ */
119
+ function connectWithoutView(connectOptions) {
120
+ return OnyxConnectionManager_1.default.connect(connectOptions);
121
+ }
94
122
  /**
95
123
  * Disconnects and removes the listener from the Onyx key.
96
124
  *
97
125
  * @example
98
126
  * ```ts
99
- * const connection = Onyx.connect({
127
+ * const connection = Onyx.connectWithoutView({
100
128
  * key: ONYXKEYS.SESSION,
101
129
  * callback: onSessionChange,
102
130
  * });
@@ -104,7 +132,7 @@ function connect(connectOptions) {
104
132
  * Onyx.disconnect(connection);
105
133
  * ```
106
134
  *
107
- * @param connection Connection object returned by calling `Onyx.connect()`.
135
+ * @param connection Connection object returned by calling `Onyx.connect()` or `Onyx.connectWithoutView()`.
108
136
  */
109
137
  function disconnect(connection) {
110
138
  OnyxConnectionManager_1.default.disconnect(connection);
@@ -612,6 +640,7 @@ function setCollection(collectionKey, collection) {
612
640
  const Onyx = {
613
641
  METHOD: OnyxUtils_1.default.METHOD,
614
642
  connect,
643
+ connectWithoutView,
615
644
  disconnect,
616
645
  set,
617
646
  multiSet,
@@ -629,6 +658,8 @@ function applyDecorators() {
629
658
  // @ts-expect-error Reassign
630
659
  connect = (0, metrics_1.default)(connect, 'Onyx.connect');
631
660
  // @ts-expect-error Reassign
661
+ connectWithoutView = (0, metrics_1.default)(connectWithoutView, 'Onyx.connectWithoutView');
662
+ // @ts-expect-error Reassign
632
663
  set = (0, metrics_1.default)(set, 'Onyx.set');
633
664
  // @ts-expect-error Reassign
634
665
  multiSet = (0, metrics_1.default)(multiSet, 'Onyx.multiSet');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "2.0.122",
3
+ "version": "2.0.123",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",