ContextAwareKt

public final class ContextAwareKt


Summary

Public methods

static final @NonNull R
<R extends Object> ContextAwareKt.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

ContextAwareKt.withContextAvailable

@NonNull
public static final R <R extends Object> ContextAwareKt.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.