Please enable JavaScript.
Coggle requires JavaScript to display documents.
Android (Kotlin), Kotlin, Differences bt Suspend and Flows, Producer👧🏻,…
Android (Kotlin)
OBSERVABLES
SharedFlow
-
- One Time Event Channel
- Cannot have a null value
- Use as MutableSharedFlow (Mutable - can be changed)
Subscribing to a YouTube channel and getting notified whenever they upload a new video.Showing Up a Snackbars.
-
Flow
- Cold Flow (Only Emit if there is a Collector)
- Cannot hold / Store Data
- Flow should collected --> .collect()
StateFlow
- Emit to collectors who are subscribes
- Cannot have a null value
- Use as MutableStateFlow
- Can be made lifecycle aware using LifecycleScope/ ViewmodelScope etc..
- ✅ Jetpack Compose
Tracking and displaying the view count of a video on YouTube.
-
- Hot Flow (Emit even if there is no Collector)
- Store the last known value
- Support Mutliple Collectors
-
LiveData
- Can have a null value
- Lifecycle aware
- Same as stateflow( save state)
- ✅Native Apps (Java, xml)
Kotlin
sealed class
Representing restricted class hierarchies; all subclasses must be defined within the same file or package
sealed class Result {
data class Success(val data: List<String>) : Result()
data class Error(val message: String) : Result()
}
-
-
-
object class
Singleton only one instance can be created, constants
-
-
-
-
-
-
-
-
-