-
Notifications
You must be signed in to change notification settings - Fork 157
make map_message generic #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah, I encountered it a few times, too. In I wanted to change it, but it's not a super simple, because there are many dependencies. impl<Ms: 'static, GMs> Effect<Ms, GMs> {
pub fn map_message_with_fn_once<OtherMs: 'static>(
self,
f: impl FnOnce(Ms) -> OtherMs + 'static + Clone,
) -> Effect<OtherMs, GMs> {
match self {
Effect::Msg(msg) => Effect::Msg(f(msg)),
Effect::Cmd(cmd) => Effect::Cmd(Box::new(cmd.map(f.clone()).map_err(f))),
Effect::GMsg(g_msg) => Effect::GMsg(g_msg),
Effect::GCmd(g_cmd) => Effect::GCmd(g_cmd),
}
}
} |
I'm hitting this quite a bit as well. Would be very useful to have this closure support. |
Like this one: form![
raw_ev(Ev::Submit, |event| {
event.prevent_default();
Msg::FormSubmitted(article_slug) // fails because of article_slug
}),
... I'll try to implement support for closures for map_message and event handlers. |
Yep |
Closing, due to @MartinKavik 's fix. |
I encoutered a problem when trying to grow my app into having a sub - (view/update/Msg/Model).
This will not compile because map_message is not accepting closures, needs to be generic to do that.
In my case it has be a closure since it is dynamically adding an unique identifier to each message.
The text was updated successfully, but these errors were encountered: