toothpick-runtime / toothpick.configuration / Configuration

Configuration

open class Configuration : RuntimeCheckConfiguration, MultipleRootScopeCheckConfiguration

Strategy pattern that allows to change various behaviors of Toothpick. The default configuration is #forProduction(). A custom configuration can be created and used by toothpick, it is even possible to use a composition of the built-in configurations.

Constructors

<init>

Configuration()

Strategy pattern that allows to change various behaviors of Toothpick. The default configuration is #forProduction(). A custom configuration can be created and used by toothpick, it is even possible to use a composition of the built-in configurations.

Functions

allowMultipleRootScopes

open fun allowMultipleRootScopes(): Configuration

Allows multiple root scopes in the scope forest.

checkCyclesEnd

open fun checkCyclesEnd(clazz: Class<Any>, name: String): Unit

checkCyclesStart

open fun checkCyclesStart(clazz: Class<Any>, name: String): Unit

checkIllegalBinding

open fun checkIllegalBinding(binding: Binding<Any>, scope: Scope): Unit

checkMultipleRootScopes

open fun checkMultipleRootScopes(scope: Scope): Unit

forDevelopment

open static fun forDevelopment(): Configuration

Performs many runtime checks. This configuration reduces performance. It should be used only during development. The checks performed are:

  • cycle detection: check that not 2 classes depend on each other. Note that if of them uses a Lazy instance of the other or a Producer, then there is no such cycle.
  • illegal binding detection: check no scope annotated class is used as the target of a binding.

forProduction

open static fun forProduction(): Configuration

Performs no runtime checks. This configuration is faster than #forDevelopment(). It can be used in production.

onScopeForestReset

open fun onScopeForestReset(): Unit

preventMultipleRootScopes

open fun preventMultipleRootScopes(): Configuration

Prevents the creation of multiple root scopes in the scope forest. TP scope forest will be restricted to a scope tree. On android this option can help to detect when a scope is reopened after it was destroyed.