ssannandeji/Zenject-2019

Initializing a Subcontainer using PrefabFactory

Opened this issue · 4 comments

I see that I can initialize a subcontainer from a new prefab using:
Container.BindFactory<Object, Param, ThingToCreate, ThingToCreate.Factory>().FromSubContainerResolve().ByNewContextPrefab<Installer>(SubContainerPrefab)

But what If I want to use a prefab factory, instead of specifying an explicit prefab to use?

Yep you're right there isn't really an easy way to do this currently

Normally I'd suggest using a custom factory but this specific case is tricky, because you want to pass the arguments to the given Installer type, so you have to reproduce some of the logic inside SubContainerCreatorByNewPrefabWithParams.cs for that.

@svermeulen thanks for pointing me to that class. I'll try digging a little deeper.

@svermeulen I think I'm a little in over my head. Is there any more info you can provide on how to set this up?