Commit Graph
2 Commits
Author SHA1 Message Date
John Costa cece12b57e docs: clarify difference between use_context and consume_context (#5406)
* docs: clarify difference between use_context and consume_context

Document the key distinction: use_context is a hook that captures the
context value once on first render and caches it, following the rules
of hooks. consume_context reads directly from the runtime each time
and can be called from anywhere (event handlers, async tasks, etc.).

Fixes #3862

* fix: remove redundant explicit rustdoc link targets

* fix: use plain text for cross-crate use_context reference in rustdoc
2026-03-24 08:10:13 -05:00
John CostaandEvan Almloff b7958d3d17 feat(signals): add WritableResultExt trait (#5338)
* feat(signals): add WritableResultExt trait

Add WritableResultExt mirroring the existing ReadableResultExt,
providing mutable access to signal values holding Result<T, E>.

Methods:
- as_mut(): returns Result<WritableRef<T>, WritableRef<E>>
- unwrap_mut(): returns WritableRef<T>, panics if Err

Closes #5293

* refactor(signals): use descriptive expect messages in WritableResultExt::as_mut

Replace bare .unwrap() calls with .expect() containing a descriptive
message about the failure mode. This gives better diagnostics if the
Result variant changes between the read and write lock acquisitions.

* switch to a single write to avoid race conditions with sync signals

---------

Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
2026-03-09 14:10:15 -07:00