bevyengine / bevyengine/bevy

Replace `RemovedComponents` with observers

Open
#13,928 8 comments 2 reactions 0 assignees View on GitHub
A-ECS C-Code-Quality C-Usability D-Wicked S-Needs-Design X-Needs-SME
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

[`RemovedComponents`](https://docs.rs/bevy/latest/bevy/ecs/prelude/struct.RemovedComponents.html) isn't a particularly nice tool: it doesn't fit into our existing tools for responding to changes well, doesn't allow users to read the data as it's being removed, must be continually monitored to avoid missing events, and risks desynchronization because of the polling-based mechanism.

## What solution would you like?

Observers (merged in https://github.com/bevyengine/bevy/pull/10839) offer an alternative solution to this problem space without the caveats.

We should deprecate and then remove [`RemovedComponents`], being careful to update and improve documentation and write a clear migration guide.

In particular, users can emit events, triggered by an observer, to recreate the previous polling-style behavior when it is preferred.

## What alternative(s) have you considered?

Other solutions to solve and/or work around the problem presented.

## Additional context

#2148 proposes a `Removed` query filter, which might still be a valuable (if complex) complement even with this PR implemented.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.