Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Contract names for parenting instead of LifetimeScope derived class type #643

Open
Maesla opened this issue Mar 12, 2024 · 0 comments
Open

Comments

@Maesla
Copy link

Maesla commented Mar 12, 2024

One of the most useful features from Zenject was parenting by contract name
https://github.com/Mathijs-Bakker/Extenject?tab=readme-ov-file#scene-parenting-using-contract-names

image

With contract names, you could define which contract the LifteTimeScope resolves and in the parenting relationship, which contract the LifteTimeScope expects to be resolved

This would allow a lossy couple relationship between child and parent. You can define the parent contract but it is not necessary to implement an specific LifteTimeScope to register the instances

For example, you can define the Parent Contract as "Settings" and these settings could be registered by SettingsLifeTimeScope or by DebugSettingsLifeTimeScope

This would also allow for me the more important feature, to have a list of default contract names, maybe in the VContainerSettings, where you can define a key value collection of default LifteTimeScope that matches the contract. If the contract is not found and it is defined in the list, it is created. This is extremely useful for multi scene architecture where one scene depends on the other and you want to run the scene independently with debug values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant