Skip to content

Commit

Permalink
Remove Await composable function that passes Loadable as an argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ogaclejapan committed May 12, 2024
1 parent 44428e9 commit c2af7d1
Showing 1 changed file with 0 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,6 @@ import soil.query.compose.QueryRefreshErrorObject
import soil.query.compose.QuerySuccessObject
import soil.query.internal.uuid

@Composable
inline fun <T> Await(
state: Loadable<T>,
key: Any? = null,
host: AwaitHost = LocalAwaitHost.current,
content: @Composable (T) -> Unit
) {
val id = remember(key) { key ?: uuid() }
when (state) {
is Loadable.Fulfilled -> content(state.data)
is Loadable.Rejected,
is Loadable.Pending -> Unit
}
LaunchedEffect(id, state) {
host[id] = state is Loadable.Pending
}
DisposableEffect(id) {
onDispose {
host.remove(id)
}
}
}

/**
* Await for a [QueryModel] to be fulfilled.
*
Expand Down

0 comments on commit c2af7d1

Please sign in to comment.