value property
Retrieves the current state, projecting any nested Cell as
unmodifiable.
This ensures deep immutability – if the state is itself a Cell, it
returns state.unmodifiable.
Implementation
@override
V? get value {
final state = _nucleus.state.value;
if (state != null) {
if (state is Cell) {
return state.unmodifiable as V?;
}
}
return state;
}
Rejects direct state mutation on the projection.
The inherited _emit path calls the shared receptor directly and
bypasses validate, so the setter must be sealed explicitly. This is
intentionally loud (throws, matching UnmodifiableListView) rather
than silently ignoring the write — the caller's intent is almost
certainly a bug.
Implementation
@override
set value(V? value) {
throw UnsupportedError(
'UnmodifiableValueCell: cannot assign `value` on a read-only '
'projection. Mutate the principal returned by `Cell.state(...).cell`.',
);
}