- convert callback to coroutine to avoid callback hell using suspendCoroutine
Make Any Callback a Suspend Function in Kotlin 🤯 #Shorts
Coroutines in Kotlin are a blessing if you dealt with callbacks before. However you still often get callbacks you would…
suspendCoroutine does not change the
CoroutineContext. It simply converts callback to suspend function which is more manageable.
declaration-site variance: you can annotate the type parameter
Sourceto make sure that it is only returned (produced) from members of
Source<T>, and never consumed.
What is out keyword in kotlin
The variance modifiers out and in allow us to make our generic types less restrictive and more reusable by allowing…
In and out type variant of Kotlin
If you ever defined generic in Kotlin, you’ll notice many a times, it would propose to use the in or out keyword to…
3. inline function
When using inline functions, there is no extra object allocation and no extra virtual method calls.