Skip to content

Toothpick Extensions

Stéphane Nicolas edited this page Aug 6, 2019 · 4 revisions

Toothpick offers various extension modules.

KTP

A whole wiki page will be dedicated to KTP.

Smoothie

Smoothie is the core Android extension for Toothpick. SmoothieActivityModule and SmoothieApplicationModule provide common bindings to inject common Android components.

Smoothie Support

SmoothieSupportActivityModule provides common Support Library bindings.

Smoothie AndroidX

SmoothieAndroidXActivityModule provides common Android X bindings.

AndroidX lifecycle

Provides the extension method: LifecycleUtil.closeOnDestroy() which can be used to close a scope automatically when a fragment activity is destroyed.

AndroidX lifecycle Kotlin

Kotlin version of the above. Provides the extension method: LifecycleUtilExtensionKt#closeOnDestroy which can be used to close a scope automatically when a fragment activity is destroyed.

AndroidX ViewModel

Provides the util method ViewModelUtil#closeOnViewModelCleared() which can be used to close a scope automatically when a fragment activity's view models are cleared.

The method ViewModelUtil#installViewModelBinding() allows to create a binding in a Scope to inject a view model. Note that the instance will itself be injected using this scope.

AndroidX ViewModel Kotlin

Kotlin version of the above. Provides the extension method: Scope.closeOnViewModelCleared which can be used to close a scope automatically when a fragment activity's view models are cleared.

The extension Scope.installViewModelBinding() allows to create a binding in a Scope to inject a view model. Note that the instance will itself be injected using this scope.

Toothpick Testing

Toothpick core testing functionalities. Support easymock, mockito, and mockk.

A whole wiki page is dedicated to Unit Testing with TP.

Toothpick Testing Junit 4

Support for Junit 4. Adds a Junit 4 rule to TP testing.

Toothpick Testing Junit 5

Support for Junit 5. Adds an JUnit 5 extension to TP testing.

Links