I'm trying to modularize the game of life example to learn about how to nest up component in yew. I separate the Cellule as a idependent component so that I could reuse the component in other form of game of life. So I impl it like:
I think this would decouple the Cellule and GameOfLife, but I failed.
Actual Results
It reminds me that I have to use the Message of COMP type, which means I can't decouple the Cellule with GameOfLife as an independent component
error[E0271]: type mismatch resolving `<COMP as yew::html::Component<CTX>>::Mess age == cellule::Msg`
--> src\cellule.rs:83:9
|
83 | / html! {
84 | | <div class=("game-cellule", if self.life_state == LifeState::A live { "cellule-live" } else { "cellule-dead" }),
85 | | onclick=|_| Msg::Toggle,> </div>
86 | | }
| |_________^ expected associated type, found enum `cellule::Msg`
|
= note: expected type `<COMP as yew::html::Component<CTX>>::Message`
found type `cellule::Msg`
= note: required because of the requirements on the impl of `yew::virtual_dom ::Listener<CTX, COMP>` for `yew::html::onclick::Wrapper<[closure@<html_impl macr os>:50:15: 50:19]>`
= note: required for the cast to the object type `yew::virtual_dom::Listener< CTX, COMP>`
= note: this error originates in a macro outside of the current crate (in Nig htly builds, run with -Z external-macro-backtrace for more info)
Description
I'm submitting a question
I'm trying to modularize the game of life example to learn about how to nest up component in yew. I separate the
Cellule
as a idependent component so that I could reuse the component in other form of game of life. So I impl it like:and In the
GameOfLife
model, I call the the view method like:Expected Results
I think this would decouple the
Cellule
andGameOfLife
, but I failed.Actual Results
It reminds me that I have to use the
Message
ofCOMP
type, which means I can't decouple theCellule
withGameOfLife
as an independent componentContext (Environment)