square / Cleanse

Lightweight Swift Dependency Injection Framework
Other
1.78k stars 90 forks source link

Retain subcomponent graphs. #122

Closed sebastianv1 closed 4 years ago

sebastianv1 commented 4 years ago

Subcomponents today are fairly buggy. Graph instances that are required to construct subcomponents cause exceptions on build(:). In order to fix this, we need something to retain Graph object instances.

This change puts the retention responsibility on ComponentFactory. ComponentFactory is now responsible for retaining all live instances of subgraphs (aka subcomponents) that it creates via the build(:) function. Subgraphs will be deinitialized alongside ComponentFactory.