merge
fun <T1, T2, R> QueryState.Companion.merge(state1: QueryState<T1>, state2: QueryState<T2>, transform: (T1, T2) -> R): QueryState<R>
fun <T1, T2, T3, R> QueryState.Companion.merge(state1: QueryState<T1>, state2: QueryState<T2>, state3: QueryState<T3>, transform: (T1, T2, T3) -> R): QueryState<R>
fun <T, R> QueryState.Companion.merge(states: Array<QueryState<T>>, transform: (List<T>) -> R): QueryState<R>
Merges multiple QueryState instances into a single QueryState instance.
Merge specification details:
QueryState.reply is combined by invoking transform only when all QueryState instances have Reply.Some. QueryState.status is selected based on the following priority order:
QueryStatus.Failure: If priorities are the same, the one with the oldest QueryState.errorUpdatedAt is selected.
QueryStatus.Pending: If priorities are the same, the left-hand side is selected.
QueryStatus.Success: If priorities are the same, the left-hand side is selected.
For most other fields, the data associated with the QueryState selected by QueryState.status will be used as is. However, QueryState.replyUpdatedAt is set to the initial value 0
only when QueryState.reply is Reply.None.