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

Simplify component state #1186

Merged
merged 2 commits into from May 13, 2020
Merged

Simplify component state #1186

merged 2 commits into from May 13, 2020

Conversation

jstarry
Copy link
Member

@jstarry jstarry commented May 4, 2020

Problem

The internal component state machine is over complicated. Empty state and Destroyed state are essentially the same. The Processing state is an implementation detail and therefore unnecessary.

Changes

  • Simplify the component state machine
    • The component state is now option wrapped. None means the component doesn't exist (rather than using Empty or Destroyed).
    • We also eagerly create the component rather than using a delayed create task. I don't anticipate this causing any issues.
    • Lastly, Yew will no longer immediately call Component::render after creating a component. This revealed an assumption in a yew-functional test where we expected the component to receive an update event before being destroyed.
  • Rework functional tests to not rely on the component rendering before being destroyed
  • Add internal "force" component update mechanism

@jstarry jstarry marked this pull request as ready for review May 13, 2020 09:51
@jstarry jstarry requested review from ZainlessBrombie and removed request for ZainlessBrombie May 13, 2020 09:51
@jstarry
Copy link
Member Author

jstarry commented May 13, 2020

@ZainlessBrombie If you have time to review how this affects functional components, that'd be great!

My understanding is that this change makes eager component deletion more consistent since we don't couple component creation with rendering anymore. And so, if a parent decides to render and then not-render a child component, it's possible that a functional component will not be able to update itself to apply an effect before being destroyed.

I think we could take this one step further by splitting component update tasks from component render tasks. Which would mean that child components would not be rendered at all if they were immediately deleted.

@jstarry jstarry merged commit 657c917 into yewstack:master May 13, 2020
@jstarry jstarry deleted the remove-states branch May 13, 2020 11:04
jstarry added a commit that referenced this pull request May 14, 2020
* Simplify component state

* Add another test
jstarry added a commit to jstarry/yew that referenced this pull request May 14, 2020
* Simplify component state

* Add another test
mergify bot pushed a commit that referenced this pull request May 14, 2020
* Simplify component state

* Add another test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant