You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<dd><p>Write a value to our store with the given key</p>
19
23
</dd>
20
24
<dt><ahref="#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
+
<aname="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
<aname="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
Copy file name to clipboardExpand all lines: lib/Onyx.ts
+35-3Lines changed: 35 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -81,10 +81,11 @@ function init({
81
81
82
82
/**
83
83
* Connects to an Onyx key given the options passed and listens to its changes.
84
+
* This method will be deprecated soon. Please use `Onyx.connectWithoutView()` instead.
84
85
*
85
86
* @example
86
87
* ```ts
87
-
* const connection = Onyx.connect({
88
+
* const connection = Onyx.connectWithoutView({
88
89
* key: ONYXKEYS.SESSION,
89
90
* callback: onSessionChange,
90
91
* });
@@ -107,20 +108,48 @@ function connect<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKey>): Co
107
108
returnconnectionManager.connect(connectOptions);
108
109
}
109
110
111
+
/**
112
+
* Connects to an Onyx key given the options passed and listens to its changes.
113
+
*
114
+
* @example
115
+
* ```ts
116
+
* const connection = Onyx.connectWithoutView({
117
+
* key: ONYXKEYS.SESSION,
118
+
* callback: onSessionChange,
119
+
* });
120
+
* ```
121
+
*
122
+
* @param connectOptions The options object that will define the behavior of the connection.
123
+
* @param connectOptions.key The Onyx key to subscribe to.
124
+
* @param connectOptions.callback A function that will be called when the Onyx data we are subscribed changes.
125
+
* @param connectOptions.waitForCollectionCallback If set to `true`, it will return the entire collection to the callback as a single object.
126
+
* @param connectOptions.withOnyxInstance The `withOnyx` class instance to be internally passed. **Only used inside `withOnyx()` HOC.**
127
+
* @param connectOptions.statePropertyName The name of the component's prop that is connected to the Onyx key. **Only used inside `withOnyx()` HOC.**
128
+
* @param connectOptions.displayName The component's display name. **Only used inside `withOnyx()` HOC.**
129
+
* @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.**
130
+
* Using this setting on `useOnyx()` or `withOnyx()` can have very positive performance benefits because the component will only re-render
131
+
* when the subset of data changes. Otherwise, any change of data on any property would normally
132
+
* cause the component to re-render (and that can be expensive from a performance standpoint).
133
+
* @returns The connection object to use when calling `Onyx.disconnect()`.
0 commit comments