FlowLiveDataConversions

public final class FlowLiveDataConversions


Summary

Public constructors

Public methods

static final @NonNull Flow<@NonNull T>
<T extends Object> FlowLiveDataConversions.asFlow(LiveData<T> receiver)

Creates a Flow containing values dispatched by originating LiveData: at the start a flow collector receives the latest value held by LiveData and then observes LiveData updates.

static final @NonNull LiveData<@NonNull T>
<T extends Object> FlowLiveDataConversions.asLiveData(
    Flow<T> receiver,
    CoroutineContext context,
    long timeoutInMs
)

Creates a LiveData that has values collected from the origin Flow.

static final @RequiresApi(value = 26) @NonNull LiveData<@NonNull T>
<T extends Object> FlowLiveDataConversions.asLiveData(
    Flow<T> receiver,
    CoroutineContext context,
    Duration timeout
)

Creates a LiveData that has values collected from the origin Flow.

Public constructors

FlowLiveDataConversions

public final FlowLiveDataConversions()

Public methods

FlowLiveDataConversions.asFlow

public static final @NonNull Flow<@NonNull T> <T extends Object> FlowLiveDataConversions.asFlow(LiveData<T> receiver)

Creates a Flow containing values dispatched by originating LiveData: at the start a flow collector receives the latest value held by LiveData and then observes LiveData updates.

When a collection of the returned flow starts the originating LiveData becomes active. Similarly, when a collection completes LiveData becomes inactive.

BackPressure: the returned flow is conflated. There is no mechanism to suspend an emission by LiveData due to a slow collector, so collector always gets the most recent value emitted.

FlowLiveDataConversions.asLiveData

public static final @NonNull LiveData<@NonNull T> <T extends Object> FlowLiveDataConversions.asLiveData(
    Flow<T> receiver,
    CoroutineContext context,
    long timeoutInMs
)

Creates a LiveData that has values collected from the origin