SystemId scene templating#24087
Conversation
|
Glad to see my idea from #24072 (comment) had some merit! I won't approve yet, since i've only looked through it on my phone, but it already seems far simpler. |
|
This was proposed basically 1:1 in #24026 (this was later changed though). The issue is that it's unclear who owns these systems, that is who is responsible for unregistering them once they are no longer needed. Given that recreating the template will spawn the system again this basically becomes a memory leak. |
Hm, are you sure this is the case even tho in build_template it only registers the system the first time its called, switching over to storing the SystemId after the first call? |
If you recreate the template (e.g. you call |
Objective
Arcify one-shot systems to enableSystemIdtemplating #24072I have a bunch of
Bundle-style code that I want to replace with the newbsn!Scene-style macro:Solution
This solution is more inspired by how
HandleTemplateworks.SystemIdTemplate; it stores either aSystemIdor aArc<Mutex<Either<SystemId, Box<dyn System>>>>system_valuefunction for wrapping system functions (see Future Work for potentially removing the need)Testing
SystemIdTemplate.callbacksexample demonstrating how to spawnSystemIds via BSN scenes.Future work
system_valueby introducingSuperFrom/SuperIntotraits a la Dioxus and using it in thebsn!macros in-place of the implicit.into()s.Showcase
You can now spawn components containing
SystemIds viabsn!macros: