obsidian
obsidian copied to clipboard
Singleton providers leak non-singleton dependencies
In the following example, useCase
is retained throwout the lifespan of all PushedScreenGraph
instances, while presenter
is meant to be retained only for the lifespan of the PushedScreen
component this graph instance is bound to.
@Graph()
class PushedScreenGraph {
@Provides()
presenter(): PushedScreenPresenter {
return new PushedScreenPresenter();
}
@Provides() @Singleton()
someUseCase(presenter: PushedScreenPresenter): SomeUseCase {
return new SomeUseCase(presenter);
}
}