Skip to content

Commit 1ef2065

Browse files
authored
Create ResultCall to simplify creation of calls with a pre-calculated result (#182)
1 parent 4d8e095 commit 1ef2065

4 files changed

Lines changed: 11 additions & 0 deletions

File tree

stream-result-call/api/android/stream-result-call.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public final class io/getstream/result/call/CallKt {
3030
public static final fun forceNewRequest (Lio/getstream/result/call/Call;)Lio/getstream/result/call/Call;
3131
public static final fun launch (Lio/getstream/result/call/Call;Lkotlinx/coroutines/CoroutineScope;)V
3232
public static final fun map (Lio/getstream/result/call/Call;Lkotlin/jvm/functions/Function1;)Lio/getstream/result/call/Call;
33+
public static final fun of (Lio/getstream/result/call/Call;Lio/getstream/result/Result;)Lio/getstream/result/call/Call;
3334
public static final fun onErrorReturn (Lio/getstream/result/call/Call;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;)Lio/getstream/result/call/ReturnOnErrorCall;
3435
public static final fun retry (Lio/getstream/result/call/Call;Lkotlinx/coroutines/CoroutineScope;Lio/getstream/result/call/retry/RetryPolicy;)Lio/getstream/result/call/Call;
3536
public static final fun share (Lio/getstream/result/call/Call;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function0;)Lio/getstream/result/call/Call;

stream-result-call/api/jvm/stream-result-call.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public final class io/getstream/result/call/CallKt {
3030
public static final fun forceNewRequest (Lio/getstream/result/call/Call;)Lio/getstream/result/call/Call;
3131
public static final fun launch (Lio/getstream/result/call/Call;Lkotlinx/coroutines/CoroutineScope;)V
3232
public static final fun map (Lio/getstream/result/call/Call;Lkotlin/jvm/functions/Function1;)Lio/getstream/result/call/Call;
33+
public static final fun of (Lio/getstream/result/call/Call;Lio/getstream/result/Result;)Lio/getstream/result/call/Call;
3334
public static final fun onErrorReturn (Lio/getstream/result/call/Call;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;)Lio/getstream/result/call/ReturnOnErrorCall;
3435
public static final fun retry (Lio/getstream/result/call/Call;Lkotlinx/coroutines/CoroutineScope;Lio/getstream/result/call/retry/RetryPolicy;)Lio/getstream/result/call/Call;
3536
public static final fun share (Lio/getstream/result/call/Call;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function0;)Lio/getstream/result/call/Call;

stream-result-call/src/commonMain/kotlin/io/getstream/result/call/Call.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ public fun <T : Any> Call<T>.share(
191191
return SharedCall(this, identifier, scope)
192192
}
193193

194+
/**
195+
* Create a [Call] from the given [Result].
196+
*/
197+
public fun <T : Any> Call<T>.of(
198+
result: Result<T>
199+
): Call<T> {
200+
return ResultCall(result)
201+
}
202+
194203
public fun Call<*>.toUnitCall(): Call<Unit> = map {}
195204

196205
private val onSuccessStub: (Any) -> Unit = {}

stream-result-call/src/androidTest/kotlin/io/getstream/result/call/ResultCall.kt renamed to stream-result-call/src/commonMain/kotlin/io/getstream/result/call/ResultCall.kt

File renamed without changes.

0 commit comments

Comments
 (0)