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

Reactive components prototype #16422

Closed
wants to merge 7 commits into from
Closed

Conversation

JMS55
Copy link
Contributor

@JMS55 JMS55 commented Nov 18, 2024

Objective

  • Initial prototype for reactivity in Bevy

Solution

  • A new ReactiveComponent type that automatically inserts and updates a component of type Output on the same entity whenever the source entity's component of type Input changes (as detected by change detection ticks)

Implementation issues

  • There's a single place where reactive components get updated (the Last schedule). Ideally it would be an immediate reaction like how observers work.
  • The update_reactive_components driver system loops over every single expression any time an expression changes. It would be ideal if we could track affected components, and only re-run expressions that would be affected. But for the initial prototype, performance isn't too important anyways.

Not implemented/tested

  • ReactiveComponents that can add/remove the component, instead of just modifying the value.
  • Chaining reactions
  • Expressions that depend on multiple components from an entity
  • Expressions that depend on multiple entities
  • Expressions that depend on resources
  • Expressions that depend on queries or other complicated sources of data
  • Reactive entity tree structures (e.g. a reactive version of WithChildren/WithChild, using the Name component as a key)

@JMS55 JMS55 added A-ECS Entities, components, systems, and events X-Controversial There is active debate or serious implications around merging this PR labels Nov 18, 2024
@JMS55 JMS55 added this to the 0.16 milestone Nov 18, 2024
@alice-i-cecile alice-i-cecile added the A-UI Graphical user interfaces, styles, layouts, and widgets label Nov 19, 2024
@JMS55
Copy link
Contributor Author

JMS55 commented Nov 27, 2024

I think template + diffing approaches are the better move here. Change detection is too difficult to get working well I feel.

@JMS55 JMS55 closed this Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events A-UI Graphical user interfaces, styles, layouts, and widgets X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants