Add events that fire before components are activated
See original GitHub issueSummary
In order to integrate Singularity with duality I would like the dependencies to be injected before components are activated. Currently duality does not provide a event for this.
Iam currently using Scene.ComponentAdded
and Scene.Entered
for this purpose except for the fact they fire after component activation.
Analysis
- Can be used to do quite neat stuff such as IOC
- Like all things can also be abused.
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Fire Component Events | Lightning Aura ...
Fire a component event to communicate data to another component. A component event can be handled by the component that fired the event...
Read more >Creating and triggering events - MDN Web Docs - Mozilla
This article demonstrates how to create and dispatch DOM events. Such events are commonly called synthetic events, as opposed to the events ......
Read more >Event handling (overview) - Event reference - MDN Web Docs
Events are signals fired inside the browser window that notify of changes in the browser or operating system environment.
Read more >Dynamically creating JavaScript elements with event ...
This tutorial explores the concepts of events, event listeners, and dynamically creating new JavaScript elements by using document.
Read more >React onClick function fires on render - javascript
I use a .map() function to display my list of objects(like in the example given in react tutorial page), but the button in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah ok makes sense. Not sure how you could word it better than what you did.
Before we start adding events all over the place let me clarify why I have a need for these events in the first place. Normally with DI constructor injection is preferred. However I do not know if this is possible in duality as duality itself calls these constructors. This is why I went for plan B and wanted to do it through method injection using those events. If you think constructor injection is still possible (maybe I can hook into the component creation logic somehow?) then I would prefer that route ofcourse.
Just FYI so I don’t keep thinking inside this event solution box.
EDIT: Found the logic creating the instances in
ObjectCreator
and inGameObject.AddComponent
. Without engine modifications it doesn’t seem to be possible to put custom logic in here.EDIT2: If we decide to change the logic here its not needed to change the current
GameObject.AddComponent
at all. You can make a new extension method that will be used when the type has a constructor with parameters (only works in C#7.3!):Ill release Singularity as a v0 version then with the warning this issue is yet to addressed