Skip to content

Commit 6c274ec

Browse files
swami-sanapathialxhub
authored andcommitted
docs(core): remove documentation of mutate function (angular#52435)
PR Close angular#52435
1 parent d7c4f56 commit 6c274ec

File tree

2 files changed

+1
-24
lines changed

2 files changed

+1
-24
lines changed

aio/content/guide/signals.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,6 @@ or use the `.update()` operation to compute a new value from the previous one:
3535
count.update(value => value + 1);
3636
```
3737

38-
When working with signals that contain objects, it's sometimes useful to mutate that object directly. For example, if the object is an array, you may want to push a new value without replacing the array entirely. To make an internal change like this, use the `.mutate` method:
39-
40-
```ts
41-
const todos = signal([{title: 'Learn signals', done: false}]);
42-
43-
todos.mutate(value => {
44-
// Change the first TODO in the array to 'done: true' without replacing it.
45-
value[0].done = true;
46-
});
47-
```
48-
4938
Writable signals have the type `WritableSignal`.
5039

5140
### Computed signals
@@ -203,8 +192,6 @@ data.set(['test']);
203192

204193
Equality functions can be provided to both writable and computed signals.
205194

206-
For writable signals, `.mutate()` does not check for equality because it mutates the current value without producing a new reference.
207-
208195
### Reading without tracking dependencies
209196

210197
Rarely, you may want to execute code which may read signals in a reactive function such as `computed` or `effect` _without_ creating a dependency.

packages/core/primitives/signals/README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This context and getter function mechanism allows for signal dependencies of a c
1616

1717
### Writable signals: `signal()`
1818

19-
The `createSignal()` function produces a specific type of signal that tracks a stored value. In addition to providing a getter function, these signals can be wired up with additional APIs for changing the value of the signal (along with notifying any dependents of the change). These include the `.set` operation for replacing the signal value, `.update` for deriving a new value, and `.mutate` for performing internal mutation of the current value. In Angular, these are exposed as functions on the signal getter itself. For example:
19+
The `createSignal()` function produces a specific type of signal that tracks a stored value. In addition to providing a getter function, these signals can be wired up with additional APIs for changing the value of the signal (along with notifying any dependents of the change). These include the `.set` operation for replacing the signal value, and `.update` for deriving a new value. In Angular, these are exposed as functions on the signal getter itself. For example:
2020

2121
```typescript
2222
const counter = signal(0);
@@ -25,16 +25,6 @@ counter.set(2);
2525
counter.update(count => count + 1);
2626
```
2727

28-
The signal value can be also updated in-place, using the dedicated `.mutate` method:
29-
30-
```typescript
31-
const todoList = signal<Todo[]>([]);
32-
33-
todoList.mutate(list => {
34-
list.push({title: 'One more task', completed: false});
35-
});
36-
```
37-
3828
#### Equality
3929

4030
The signal creation function one can, optionally, specify an equality comparator function. The comparator is used to decide whether the new supplied value is the same, or different, as compared to the current signal’s value.

0 commit comments

Comments
 (0)