Make dispatch a public method

This commit is contained in:
Jeremy Wall 2022-12-26 17:24:14 -05:00
parent cad0b2ecb7
commit 66d1307f1b
2 changed files with 15 additions and 1 deletions

View File

@ -54,7 +54,8 @@ where
)
}
fn dispatch(&self, msg: Msg) {
/// Directly handle a state message without requiring a binding.
pub fn dispatch(&self, msg: Msg) {
self.signal.set(self.dispatcher.map(msg, self.signal))
}

View File

@ -24,6 +24,19 @@ pub struct FakeState {
value_two: i32,
}
pub enum MultiMsg {
Foo(Msg),
Bar(Msg),
}
pub struct MultiState<'ctx, D>
where
D: MessageMapper<Msg, FakeState>,
{
foo: &'ctx Handler<'ctx, D, FakeState, Msg>,
bar: &'ctx Handler<'ctx, D, FakeState, Msg>,
}
pub struct StateMachine();
impl MessageMapper<Msg, FakeState> for StateMachine {