Dagger2 custom scopes and destroy component

Viewed 3643

As I understand it, when scoping components and modules, instances that are (@)provided will live as long as the components that expose them exist.

More concretely, in the case of an @User scoped component, we can drop the @provided objects (provided by the modules) that are populated with user specific data when a user logs out. When a new user logs in, we should create a new Dagger component, that in turns exposes objects that will be populated with that (newly logged in) user specific data. These objects will in turn be kept alive as long as the component is not destroyed on log out.

My question is simply, how do we destroy a (sub)component on log out?
Is it sufficient that we just set the component to null so that it can be garbage collected, and create a new component manually through the builder?

2 Answers
Related