* Writes new data to the query and marks it as successfully fetched. * @internal * @param newData - The data to write. Structural sharing with the current data is applied. * @param options - Set `updatedAt` to override the timestamp, and `manual` to mark the write as * manual (e.g. from
(
newData: TData,
options?: SetDataOptions & { manual: boolean },
)
| 388 | * @returns The data that was written. |
| 389 | */ |
| 390 | setData( |
| 391 | newData: TData, |
| 392 | options?: SetDataOptions & { manual: boolean }, |
| 393 | ): TData { |
| 394 | const data = replaceData(this.state.data, newData, this.options) |
| 395 | |
| 396 | // Set data and mark it as cached |
| 397 | this.#dispatch({ |
| 398 | data, |
| 399 | type: 'success', |
| 400 | dataUpdatedAt: options?.updatedAt, |
| 401 | manual: options?.manual, |
| 402 | }) |
| 403 | |
| 404 | return data |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Merges the given partial state directly into this query's state, notifying observers. Used |