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
-`$unaryStep` is any _unary_ step - see [Unary step usage](#unary-step-usage) below
140
+
-`ioEquivalence` is either `null`, a string, an array of strings, or a string-string object map - see [ioEquivalence usage](#ioequivalence-usage) below
141
+
- and `callback` is a callback function responsible for fetching the data.
142
+
143
+
### Callback
144
+
145
+
The `callback` function is called with two arguments, the first is
146
+
a list of the values from the _specifier step_`$spec` and the second is options that
147
+
may affect the fetching of the records.
148
+
149
+
```ts
150
+
function callback(
151
+
specs:ReadonlyArray<unknown>,
152
+
options: {
153
+
unary:unknown;
154
+
attributes:ReadonlyArray<string>;
155
+
params:Record<string, unknown>;
156
+
},
157
+
):PromiseOrDirect<ReadonlyArray<unknown>>;
158
+
```
132
159
133
160
:::tip
134
161
@@ -138,6 +165,39 @@ defined inline. This will allow LoadManyStep to optimise calls to this function.
138
165
139
166
:::
140
167
168
+
Within this definition of `callback`:
169
+
170
+
-`specs` is the runtime values of each value that `$spec` represented
171
+
-`options` is an object containing:
172
+
-`unary`: the runtime value that `$unaryStep` (if any) represented
173
+
-`attributes`: the list of keys that have been accessed via
174
+
`$record.get('<key>')` for each of the records in `$records`
175
+
-`params`: the params set via `$records.setParam('<key>', <value>)`
176
+
177
+
`specs` is deduplicated using strict equality; so it is best to keep `$spec`
178
+
simple - typically it should only represent a single scalar value - which is
179
+
why `$unaryStep` exists...
180
+
181
+
`options.unary` is very useful to keep specs simple (so that fetch
182
+
deduplication can work optimally) whilst passing in global values that you may
183
+
need such as a database or API client.
184
+
185
+
`options.attributes` is useful for optimizing your fetch - e.g. if the user
186
+
only ever requested `$record.get('id')` and `$record.get('avatarUrl')` then
187
+
there's no need to fetch all the other attributes from your datasource.
188
+
189
+
`options.params` can be used to pass additional context to your callback
190
+
function, perhaps options like "should we include archived records" or "should
191
+
we expand 'customer' into a full object rather than just returning the
0 commit comments