winter-android / io.jentz.winter.android / AndroidPresentationScopeAdapter

AndroidPresentationScopeAdapter

open class AndroidPresentationScopeAdapter : Adapter

Android injection adapter that operates on a WinterTree and retains a presentation sub graph during Activity re-creation (configuration changes).

It expects an application component like:

Winter.component {
  // this sub-graph outlives configuration changes and is only disposed when Activity
  // isFinishing == true
  subcomponent("presentation") {
    // this is recreated every time the Activity is recreated
    subcomponent("activity") {
    }
  }
}
Injection.useAndroidPresentationScopeAdapter()

The adapter registers the Application as Context and Application on the application graph and the Activity as Context and Activity on the "activity" graph.

The createGraph and disposeGraph methods support instances of Application and Activity. The retrieval method getGraph supports instances of Application, Activity, View, DependencyGraphContextWrapper and ContextWrapper.

The optional builder block for createGraph with an Activity is applied to the "activity" component createGraph NOT the "presentation" component createGraph.

getGraph called with an unknown type will return the application graph.

Constructors

<init>

AndroidPresentationScopeAdapter(tree: WinterTree)

Android injection adapter that operates on a WinterTree and retains a presentation sub graph during Activity re-creation (configuration changes).

Properties

tree

val tree: WinterTree

Functions

createGraph

open fun createGraph(instance: Any, block: ComponentBuilderBlock?): Graph

disposeGraph

open fun disposeGraph(instance: Any): Unit

getGraph

open fun getGraph(instance: Any): Graph