Skip to content

Commit 7a2652e

Browse files
Allow obtaining a AnonymousViewContext from a ViewContext (#4671)
# Description of Changes Title. Is useful to more easily reuse code. I asked @joshua-spacetime on discord if this would be reasonable and he said 👍 . This mirrors the method available on `ReducerContext` for consistency. # API and ABI breaking changes None # Expected complexity level and risk 1 - minimal api surface addition # Testing - [x] Tested in my project and works as expected. --------- Signed-off-by: joshua-spacetime <josh@clockworklabs.io> Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
1 parent 44c4b2a commit 7a2652e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

crates/bindings/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,11 @@ impl ViewContext {
950950
pub fn sender(&self) -> Identity {
951951
self.sender
952952
}
953+
954+
/// Obtain an [`AnonymousViewContext`] by dropping `sender`.
955+
pub fn as_anonymous(&self) -> AnonymousViewContext {
956+
AnonymousViewContext::default()
957+
}
953958
}
954959

955960
/// The context that any reducer is provided with.

0 commit comments

Comments
 (0)