Skip to content

Commit 2fa354a

Browse files
authored
fix: Reactive cycle improvements
Introduces improvements to the reactive cycles of signals and resources. Previously, signals holding objects were not correct evaluated for changes, causing unnecessary notifications to observers. Now, even if the signal holds an object, the object is checked for deep equality of its properties and values (as opposed to checking for object identity). Resource reactive cycles have also been improved to avoid unnecessary notifications. A resource's source function is never evaluated unless fetchWhen is true The deepCheck evaluation done for signals is also now done for resource source functions, avoiding unnecessary re-evaluation when these return an object
1 parent 4fcc5a7 commit 2fa354a

File tree

12 files changed

+854
-515
lines changed

12 files changed

+854
-515
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ Data from a resource signal comes in the following format:
392392

393393
```typescript
394394
type AsyncData<T> = {
395-
data: T | null; // The data fetched from the server. It is null until the data is fetched
395+
data: ReadOnlySignal<T> | null; // The data fetched from the server. It is null until the data is fetched
396396
loading: boolean; // A boolean that indicates if the data is being fetched
397397
error: unknown | null; // An error object that is populated if the fetch fails
398398
};
@@ -607,6 +607,9 @@ export default class ContactList extends LightningElement {
607607

608608
### Mutating `$resource` data
609609

610+
Notice that the data returned by a resource is a ReadOnlySignal.
611+
This means that you cannot mutate the data directly, so how can you update the data?
612+
610613
Besides `refetch`, the `$resource` function also returns a `mutate` function that allows you to mutate the data.
611614

612615
`mutate` is useful when you want to update the data without refetching it (and avoid a trip to the server).

0 commit comments

Comments
 (0)