Add a dispatch_and method

This commit is contained in:
Jeremy Wall 2022-12-31 16:59:40 -06:00
parent bc8854b4dd
commit 6490d6db4d
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "sycamore-state"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -59,6 +59,15 @@ where
self.dispatcher.map(cx, msg, self.signal)
}
/// Directly handle a state message and then run a Fn.
pub fn dispatch_and<F>(&'ctx self, cx: Scope<'ctx>, msg: Msg, f: F)
where
F: FnOnce(),
{
self.dispatch(cx, msg);
f();
}
/// Provides a ReadSignal handle for the contained Signal implementation.
pub fn read_signal(&'ctx self) -> &'ctx ReadSignal<T> {
self.signal