AppScope

abstract class AppScope(source)

A simple common app-wide scope key that can be used with SingleIn or as an aggregation scope.

AppScope must be configured by hand within your own dependency graph to be used - Metro does not perform any automatic scope configuration.

As a scope

When used with SingleIn, it will indicate a scope of the annotated graph and any bindings with matching scopes will have exactly one instance instantiated in that graph's lifecycle.

@SingleIn(AppScope::class)
@DependencyGraph
interface AppGraph {
// ...
}

As an aggregation scope

When used with DependencyGraph.scope and GraphExtension.scope, it will indicate that the annotated graph aggregates dependencies from other graphs with the same scope key.

@DependencyGraph(AppScope::class)
interface AppGraph {
// ...
}

Note that Metro treats these graphs as having an implicit SingleIn of the same key, so it's redundant to specify both!

@DependencyGraph(AppScope::class)
@SingleIn(AppScope::class) // <-- Redundant!
interface AppGraph {
// ...
}