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

Add a diagram of the component lifecycle #1915

Open
1 task done
mc1098 opened this issue Jun 12, 2021 · 1 comment
Open
1 task done

Add a diagram of the component lifecycle #1915

mc1098 opened this issue Jun 12, 2021 · 1 comment

Comments

@mc1098
Copy link
Contributor

mc1098 commented Jun 12, 2021

This is about:

  • Undocumented code

Problem

Add a diagram of the component lifecycle under 'Lifecycle' in the docs.

This issue was originally started in the yewstack/docs - Original issue. I'm just moving it over here as that repo is now archived (as proposed in #1421).

For convenience I'll just echo the original proposal below:
Render Cycle1

  1. create()
  2. view()
  3. yew renders to page
  4. mounted()

Note: should explain how children components are rendered.. (Parent view -> Child view -> Child mount -> Parent mount)

Update Cycle1

  1. trigger event / callback / send message
  2. update()
  3. (optional) view()
  4. yew renders to page

Change Cycle1

  1. render component with new props
  2. change()2
  3. (optional) view()
  4. yew renders to page

1 - Note made in original issue: "'Change cycle' and 'update cycle' should be altered slightly because they're not 'cycles' as such."
2 - In the original issue this is 'update()' which was a typo, change() is the correct method.

As noted in the original issue the diagram should be in SVG (rather than a PNG etc) as it would offer better resolution.

@mc1098
Copy link
Contributor Author

mc1098 commented Jun 16, 2021

Here is my try:
comp-lifecycle
update-events
I had to pull out the Event loop bits into a different diagram because it was bit too busy for nomnoml to make a clear diagram.
I could draw out a full diagram with the Event loop bit expanded if that's preferable but thought I'd check if all of the above is correct and covers all the requirements.

Still learning about Yew so I'm sure it will need some, or maybe a lot of, tweaking :D
Not sure if it's just worth stating that Children will always be resolved first instead of the way I've tried to show that in the diagram.

Note: Images are PNG because Github doesn't accept SVG here, but the final image for the website would be SVG

@Madoshakalaka Madoshakalaka mentioned this issue Dec 16, 2021
3 tasks
@WorldSEnder WorldSEnder mentioned this issue Apr 2, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant