ContextAwareKt

Added in 1.2.0

public final class ContextAwareKt


Summary

Public methods

static final @NonNull R
<R extends Object> withContextAvailable(
    @NonNull ContextAware receiver,
    @NonNull Function1<@NonNull Context, @NonNull R> onContextAvailable
)

Run onContextAvailable when the Context becomes available and resume with the result.

Public methods

withContextAvailable

public static final @NonNull R <R extends Object> withContextAvailable(
    @NonNull ContextAware receiver,
    @NonNull Function1<@NonNull Context, @NonNull R> onContextAvailable
)

Run onContextAvailable when the Context becomes available and resume with the result.

If the Context is already available, onContextAvailable will be synchronously called on the current coroutine context. Otherwise, onContextAvailable will be called on the UI thread immediately when the Context becomes available.