ssannandeji / Zenject-2019

Dependency Injection Framework for Unity3D
MIT License
2.53k stars 363 forks source link

Added CustomPoolableManager to work with IPoolable<T> objects in container #622

Open Cerzi opened 5 years ago

Cerzi commented 5 years ago

A very simple modified version of PoolableManager that allows a facade class to forward an initialization parameter to objects in the subcontainer that implement IPoolable<T>.

This enables a clean way for all subcomponents to access the param data sent to the facade OnSpawned:

public void OnSpawned(ParamData data, IMemroyPool pool)
{
   _pool = pool;
   _customPoolableManager.TriggerOnSpawned(data);
}

//subcomponent.cs
public void OnSpawned(ParamData data)

Rather than having to do something like

public void OnSpawned() 
{
   _data = _facade.GetData();
}

in every subcomponent, which feels like a limitation of the current PoolableManager.

svermeulen commented 5 years ago

Makes sense, thanks. I've merged this into extenject with commit 226c911b. I also added documentation for it