Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

WritableSignal

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
asReadonly(): Signal<T> }

Child interfaces

Methods

Directly set the signal to a new value, and notify any dependents.

      
      set(value: T): void
    
Parameters
value T
Returns

void

Update the value of the signal based on its current value, and notify any dependents.

      
      update(updateFn: (value: T) => T): void
    
Parameters
updateFn (value: T) => T
Returns

void

Returns a readonly version of this signal. Readonly signals can be accessed to read their value but can't be changed using set or update methods. The readonly signals do not have any built-in mechanism that would prevent deep-mutation of their value.

      
      asReadonly(): Signal<T>
    
Parameters

There are no parameters.

Returns

Signal<T>