intendednull / yewdux

Ergonomic state management for Yew applications
https://intendednull.github.io/yewdux/
Apache License 2.0
322 stars 31 forks source link

Component example not working #32

Closed DevinLeamy closed 2 years ago

DevinLeamy commented 2 years ago

I believe this is a bug in the not-stable release. At a glance, the trait requirements for Dispatch::subscribe(...) don't seem to permit the defacto yew Callback<IN> from being used.

#[derive(Default, PartialEq, Store)]
pub struct FrameStore {
    frame: i32,
}

impl Component for App {
  //...
  fn create(ctx: &Context<Self>) -> Self {
      let frame_update_callback = ctx.link().callback(Signal::UpdateFrame);
      let dispatch = Dispatch::<FrameStore>::subscribe(frame_update_callback);
      // ...
  }
  //...
}
image

On another note, just came across this project today - exactly what I was looking for! Thanks!

DevinLeamy commented 2 years ago

Turns out the example requires yew = { git = "https://github.com/yewstack/yew.git" }, rather than 0.19.3. 😄