bevyengine / bevyengine/bevy

Provide a reference to the inserted component in ON_REPLACE observer

Open
#21,274 1 comment 1 reaction 0 assignees View on GitHub
A-ECS C-Feature D-Complex X-Contentious
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

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

I don't know if this has been explored or if this a realistic ask, but I was wondering if we could provide a reference to the inserted component in the ON_REPLACE observer.

The ON_REPLACE observer gets triggered BEFORE the new component is inserted, and while we have ownership of the new component to insert on the entity.
So theoretically we could pass a reference to that new data in the ON_REPLACE observer, meaning that inside the observer users could query the existing component value to compute a diff between the old and new value.

Contributor guide

Open the contributing guide

Research direction

No file or test is named. Start by tracing the ON_REPLACE observer entry point and how the new component is held before insertion; define how an observer can receive that reference and compare existing and incoming values, then add coverage for the observer’s arguments and timing.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.