Skip to content
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

Implement PartialEq for VChild #1216

Closed
kellpossible opened this issue May 12, 2020 · 6 comments · Fixed by #1242
Closed

Implement PartialEq for VChild #1216

kellpossible opened this issue May 12, 2020 · 6 comments · Fixed by #1242
Labels
feature-request A feature request

Comments

@kellpossible
Copy link
Contributor

kellpossible commented May 12, 2020

I'm trying to use ChildrenWithProps in a component, and to implement the Component::change method correctly for a Component with the ChildrenWithProps in it's properties, however this isn't really currently possible because to derive/implement PartialEq for the component's Props requires the VChild (in the ChildrenWithProps) implements PartialEq.

My exact use case can be seen at
https://github.com/kellpossible/coster/blob/5dd0ea17d0501368812c0b9785e54a1afd197ce2/gui/yew-state/src/provider.rs#L80 and
https://github.com/kellpossible/coster/blob/5dd0ea17d0501368812c0b9785e54a1afd197ce2/gui/yew-state/src/provider.rs#L191

@kellpossible kellpossible added the feature-request A feature request label May 12, 2020
@kellpossible
Copy link
Contributor Author

Related, I also noticed that VNode PartialEq implementation is missing for VComp:

// Need to improve PartialEq for VComp before enabling

Which would also imply that the Children's PartialEq implementation is also broken when it contains a Component child.

@jstarry
Copy link
Member

jstarry commented May 12, 2020

Not exactly "broken", it will just always treat component nodes as not equal.

This will all be possible when we finish up #830

@kellpossible
Copy link
Contributor Author

@jstarry thanks for the feedback! Is there anything I can do to help for that issue? I'm using these features while working on a Redux-like Provider component as an experiment for managing global state.

@jstarry
Copy link
Member

jstarry commented May 12, 2020

@kellpossible yes, I think you could but I need to do a bit of housecleaning first. I'll get back to you in a few days on this!

@jstarry jstarry removed the blocked label May 16, 2020
@jstarry
Copy link
Member

jstarry commented May 16, 2020

Hey @kellpossible, I spent some time looking into this and realized I was conflating ChildrenRenderer<VChild<CHILD>> and ChildrenRenderer<Html>. There's nothing blocking implementing PartialEq for VChild right now. I think we just need to implement it for when a component's properties implement PartialEq and comparing props should be sufficient.

Do you want to take on this task?

Here is an issue for tracking the fix for Children: #1236

@kellpossible
Copy link
Contributor Author

@jstarry okay I'll give it a crack today!

kellpossible added a commit to kellpossible/yew that referenced this issue May 17, 2020
jstarry pushed a commit that referenced this issue May 17, 2020
* #1216 implement PartialEq for VChild

* reformat vcomp.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants