Add support for retaining multiple unrelated scenes on the same entity #184
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A small follow-up on #181
EntityWorldMut::retain_scene_with::<T>
andEntityWorldMut::retain_child_scenes_with::<T>
.T
is used as a marker to store multiple receipts. This allows retention of different unrelated scenes on an entity.Why?
While playing around with widget patterns one idea that popped was to use an immutable component as "props" for a widget/schematic, with hooks to handle the instance lifecycle. Scene retention is a pretty nice way to get functionality similar to Components in libraries like React and Vue.
(⚠️ incomplete pattern below, will keep exploring it)
Let's say we want to crate an
EditorButton
widget with some "props" and aButtonState
. We'll create an immutable component with an insert hook to drive the effects that should run to update/render it:This widget can then be used in any template like so:
The nice thing about this pattern is that it is decoupled from the reactivity solution it uses. It could use
retain_scene
, or it could just spawn a scene and use systems/observers to update it, or it could use a future true reactive solution. But it doesn't matter to the consumer!