interface
developer preview
A Signal
with a value that can be mutated via a setter interface.
interface WritableSignal<T> extends Signal<T> { set(value: T): void update(updateFn: (value: T) => T): void mutate(mutatorFn: (value: T) => void): void asReadonly(): Signal<T> }
set() | |||
---|---|---|---|
Directly set the signal to a new value, and notify any dependents. | |||
|
value | T |
void
update() | |||
---|---|---|---|
Update the value of the signal based on its current value, and notify any dependents. | |||
|
updateFn | (value: T) => T |
void
mutate() | |||
---|---|---|---|
Update the current value by mutating it in-place, and notify any dependents. | |||
|
mutatorFn | (value: T) => void |
void
asReadonly() |
---|
Returns a readonly version of this signal. Readonly signals can be accessed to read their value but can't be changed using set, update or mutate methods. The readonly signals do not have any built-in mechanism that would prevent deep-mutation of their value. |
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/core/WritableSignal