This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IProviderInterface | |
data class ProviderClass(override val id: String, override val name: String = "Provider") : IProviderInterface | |
val MY_PROVIDER_SCOPE_NAME = "MY_PROVIDER_SCOPE_NAME" | |
kodi { | |
bind<IProviderInterface>() at MY_PROVIDER_SCOPE_NAME with provider { ProviderClass(UUID.randomUUID().toString()) } | |
} | |
val providerInstaceByScope = instance<IProviderInterface>(scope = MY_PROVIDER_SCOPE_NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IProviderInterface | |
data class ProviderClass(override val id: String, override val name: String = "Provider") : IProviderInterface | |
val MY_PROVIDER_SCOPE_NAME = "MY_PROVIDER_SCOPE_NAME" | |
kodi { | |
bind<IProviderInterface>() at MY_PROVIDER_SCOPE_NAME with provider { ProviderClass(UUID.randomUUID().toString()) } | |
} | |
val providerInstaceByScope = instance<IProviderInterface>(scope = MY_PROVIDER_SCOPE_NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindSingle( | |
toClass = OkHttpClient::class, | |
toModule = "OkHttpModule" | |
) | |
fun createOkHttpClient(cache: Cache? = null): OkHttpClient { | |
val httpClient = OkHttpClient.Builder() | |
httpClient.connectTimeout(60, TimeUnit.SECONDS) | |
httpClient.writeTimeout(60, TimeUnit.SECONDS) | |
httpClient.readTimeout(60, TimeUnit.SECONDS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object CustomObject { | |
@BindSingle(toClass = IAnotherClass::class) | |
fun providingMethod( | |
@WithInstance(with = "IAnotherClass::class") input: IMyClass | |
): IAnotherClass { | |
return input | |
} | |
} | |
//It is generate `Singleton` method for binding like: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IAnotherClass | |
interface IMyClass : IAnotherClass | |
@BindSingle(toClass = IMyClass::class) | |
class MyClass( | |
private val anotherOne: IAnotherClass, | |
@IgonreInstance private val ignoredReference: String = "MyIgnoredReference" | |
) : IMyClass | |
// It is generate `Singleton` method for binding like: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainApplication : Application() { | |
override fun onCreate() { | |
super.onCreate() | |
kodi { | |
import(systemModule) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val systemModule: IKodiModule = kodiModule { | |
bind<IRetrieveAndUpdateFirebaseTokenUseCase>() with provider { | |
RetrieveAndUpdateFirebaseTokenUseCase( | |
userPreference = instance<IUserPreference>(), | |
updateFirebaseTokenUseCase = instance<IUpdateFirebaseTokenUseCase>() | |
) | |
} | |
} withScope "FIREBASE_SCOPE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity(), IKodi { | |
private val myClass: MyClass by immutableInstance() // 1. | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val myClassInstance = instance<MyClass>() // 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import | |
class MainActivity : AppCompatActivity(), IKodi { | |
val myAmazingClass: MyClass by immutableInstance() // 1. | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// or you can get instance directly from DI | |
val myInstance = instance<MyClass>() // 2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
liveData(context = viewModelScope.coroutineContext + Dispatcher.IO) { | |
emitSource( | |
pagesRepository.getNextPageData(eventPageLiveData).asLiveData().map { dataList -> | |
dataList.convertToList<MyUIModel>() | |
} | |
) | |
} |
NewerOlder