okarm
09/01/2020, 3:28 PMB as a value of StateFlow<A>. I would not expect that to be possible. The code not only compiles, it actually runs in the Playground without a run-time exception.octylFractal
09/01/2020, 5:10 PMoctylFractal
09/01/2020, 5:10 PMval a = flow.value I would expect an exception as kotlin should introduce a cast thereoctylFractal
09/01/2020, 5:11 PMokarm
09/01/2020, 5:31 PMB to LiveData<A>. But it it has no problem setting B as value of StateFlow<A>wasyl
09/01/2020, 7:11 PMMutableStateFlow doesn’t perform any checks when setting value of a wrong type 🤔octylFractal
09/01/2020, 7:55 PMoctylFractal
09/01/2020, 7:56 PMokarm
09/01/2020, 8:14 PMokarm
09/01/2020, 8:25 PMpublic abstract class LiveData<T> vs public interface StateFlow<out T> - There's no out-projection in LiveDataoctylFractal
09/01/2020, 8:39 PMLiveData is a Java class, not a Kotlin one?octylFractal
09/01/2020, 8:42 PMoctylFractal
09/01/2020, 8:43 PMout T allows such things as:
interface Source<out T> {
fun nextT(): T
}
fun demo(strs: Source<String>) {
val objects: Source<Any> = strs // This is OK, since T is an out-parameter
// ...
}octylFractal
09/01/2020, 8:43 PMStateFlow<Any> from the flow and allow the unsafe setoctylFractal
09/01/2020, 8:45 PMMutableStateFlow doesn't declare out T, but just T -- since it prevents input from being promoted to Anyaraqnid
09/01/2020, 9:36 PM