android - How do Dagger 2 scoped components work? -


i'm new dagger 2 , managed grasp basic of how works, i'm confused how custom scopes works. here problem: have activityscope defined this:

@scope @retention(retentionpolicy.runtime) public @interface activityscope { } 

and scoped component:

@activityscope @component( modules = activitymodule.class) public interface activitycomponent {    /* ... */ } 

the way understand it, objects provided component have single instance lives long component lives, determines how long component lives? component built (application, inside activity, fragment ...), or else?

i don't know if right place ask question welcome. thanks.

the way understand it, objects provided component have single instance lives long component lives [...]

correct. scoped objects provided component exist once. not true unscoped objects, recreated every time , can provided component.

[...] determines how long component lives? component built (application, inside activity, fragment ...), or else?

you do. if decide store component in static variable—please don't—then component lives long app alive , running (and leak activity in process).

if keep component in activity garbage collected along rest, once activity gets destroyed.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -