intendednull / yewdux

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

in yew version = "0.21.0" and yewdux = "0.9.3" error will generated #61

Closed ghost closed 11 months ago

ghost commented 11 months ago

in use_store let (store, dispatch):(Rc,Dispatch) = usestore::(); Error: the trait bound `impl yew::functional::hooks::Hook<Output = (Rc, yewdux::dispatch::Dispatch)> + ': Hookis not satisfied the traitHookis implemented forBoxedHook<'_, T>`

intendednull commented 11 months ago

The Yew version needs to be updated. Should have some time soon to release a fix

xeho91 commented 11 months ago

The Yew version needs to be updated. Should have some time soon to release a fix

From what I found out, updating yew to v0.21.0 is not going to be enough.

There has been some breaking changes, see: yewstack/yew#3289.

I'm receiving other error, let me quickly give a sample:

#[derive(Clone, Debug, Default, PartialEq, yewdux::store::Store)]
pub struct StateSprites(RefCell<HashMap<String, SpriteData>>);

pub enum SpritesManagerMsg {
    SpritesInjected(Rc<StateSprites>),
}

pub struct SpritesManager {
    _state_listener: Dispatch<StateSprites>,
    state: Rc<StateSprites>,
    element: Element,
}

impl SpritesManager {
    const ID: &'static str = "svg-sprites";
}

impl yew::Component for SpritesManager {
    type Message = SpritesManagerMsg;
    type Properties = ();

    fn create(ctx: &yew::Context<Self>) -> Self {
        let cb = ctx.link().callback(Self::Message::SpritesInjected);
        let dispatch = Dispatch::<StateSprites>::subscribe(cb);

        // Redacted to for simplification
    }

    // Rest is redacted to for simplification
}

I'm receiving this error message on the: let dispatch = Dispatch::<StateSprites>::subscribe(cb);

Diagnostics:
1. expected a `std::ops::Fn<(std::rc::Rc<utils::sprites::store::StateSprites>,)>` closure, found `yew::Callback<std::rc::Rc<utils::sprites::store::StateSprites>>`
   the trait `std::ops::Fn<(std::rc::Rc<utils::sprites::store::StateSprites>,)>` is not implemented for `yew::Callback<std::rc::Rc<utils::sprites::store::StateSprites>>`
   the trait `yewdux::subscriber::Callable<S>` is implemented for `yew::callback::Callback<std::rc::Rc<S>>`
   required for `yew::Callback<std::rc::Rc<utils::sprites::store::StateSprites>>` to implement `yewdux::subscriber::Callable<utils::sprites::store::StateSprites>` [E0277]
2. required by a bound introduced by this call [E0277]
amiyatulu commented 11 months ago

Any updates? I am too getting the same error.