Skip to content

Conversation

@Diggsey
Copy link
Contributor

@Diggsey Diggsey commented May 4, 2021

Description

  • Moves ContextProvider to yew crate.
  • Adds context() method to ComponentLink/Scope/AnyScope
  • Switches ComponentProvider to use explicit unsubscription via a guard.
  • Re-implements use_context via scope.context()
  • Removes Rc<_> wrapper from context values, with the rationale that if the user wants that, they can add it themselves.

Fixes #1647

Checklist

  • I have run cargo make pr-flow
  • I have reviewed my own code
  • I have added tests

@Diggsey
Copy link
Contributor Author

Diggsey commented May 4, 2021

This approach is more powerful than using a ContextConsumer component, and allows you to update component state in response to context.

If desired, a ContextConsumer component could trivially be implemented on top of this though.

@siku2
Copy link
Member

siku2 commented May 5, 2021

What do you think, @hamza1311?
Especially with regards to #1841.

@ranile
Copy link
Member

ranile commented May 5, 2021

What do you think, @hamza1311?
Especially with regards to #1841.

@siku2, This builds upon code that has already been re-worked in #1780. I think that PR should be merged, yew-functional should be merged into yew and then PR should be merged.

I haven't looked too closely at the implementation yet but from what I can tell, it looks good but I don't believe it should be merged just yet.

@siku2
Copy link
Member

siku2 commented May 5, 2021

Now that that's done, would you mind updating this PR, @Diggsey?

@Diggsey
Copy link
Contributor Author

Diggsey commented May 5, 2021

Done 👍

@siku2 siku2 merged commit e2d7619 into yewstack:master May 5, 2021
@ranile ranile mentioned this pull request May 11, 2021
3 tasks
@voidpumpkin voidpumpkin added the A-yew Area: The main yew crate label Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-yew Area: The main yew crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consumer for contexts in struct components

4 participants