readonly method
Returns a cached read-only view of this writable computed value.
Use this when callers should observe the derived value but should not be able to assign through it.
Example:
final counter = Signal(0);
final writableComputed = WritableComputed(
() => counter.value,
(value) => counter.value = value,
);
final readonly = writableComputed.readonly();
Implementation
Readonly<T> readonly() {
if (this is Readonly<T>) return this as Readonly<T>;
return (_readonlys[this] ??= ReadonlyImpl(this)) as Readonly<T>;
}