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

use_bridge hook for agents #2125

Merged
merged 10 commits into from
Nov 12, 2021
Merged

use_bridge hook for agents #2125

merged 10 commits into from
Nov 12, 2021

Conversation

futursolo
Copy link
Member

Description

This PR adds a use_bridge hook to yew-agent which does the following:

  • Bridges to the specified agent once throughout the entire lifecycle of the component.
  • Update the Callback to be the latest every time the component is rendered to prevent stale values in the callback.

Fixes #2112 (Partially)

Checklist

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

@futursolo
Copy link
Member Author

The clippy error is solved in #2126.

Copy link
Member

@voidpumpkin voidpumpkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the idea of having a dedicated hook for connecting to agents.

Could you also add documentation for this new hook?
In website/docs/concepts/function-components/pre-defined-hooks.md

@voidpumpkin voidpumpkin added the A-yew-agent Area: The yew-agent crate label Nov 11, 2021
@futursolo
Copy link
Member Author

futursolo commented Nov 11, 2021

I love the idea of having a dedicated hook for connecting to agents.

Could you also add documentation for this new hook? In website/docs/concepts/function-components/pre-defined-hooks.md

I think the documentation of yew_agent::use_bridge belongs to the agent section, not the pre defined hooks section since it is not in the yew crate or yew::prelude.

However, the docs for agents currently do not have any information on how to actually use them which is why I didn't add any documentation.

@voidpumpkin
Copy link
Member

@futursolo My view on this would be that having documentation, even if its in a not separate place would be good.
Perhaps It will be worth to refactor out agents section or something in the future, but for this PR scope, having something in pre-defined hooks section, in my opinion, would be enough.

@voidpumpkin
Copy link
Member

@futursolo Further looking at the docs I see that under https://yew.rs/next/concepts/agents#bridges adding simple mention about this hook would probably be enough.

@github-actions
Copy link

Visit the preview URL for this PR (updated for commit bf75666):

https://yew-rs--pr2125-use-bridge-vl5ko9gg.web.app

(expires Fri, 19 Nov 2021 02:03:21 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@voidpumpkin voidpumpkin enabled auto-merge (squash) November 12, 2021 06:08
@voidpumpkin voidpumpkin merged commit fb9c398 into yewstack:master Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew-agent Area: The yew-agent crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UseStateHandle can become stale
3 participants