File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
android/library/src/main/java/io/appwrite/coroutines
kotlin/src/main/kotlin/io/appwrite/coroutines Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ package {{ sdk .namespace | caseDot }}.coroutines
2
+
3
+ import kotlinx.coroutines.Dispatchers
4
+ import kotlin.coroutines.Continuation
5
+ import kotlin.coroutines.CoroutineContext
6
+
7
+ interface Callback<T > {
8
+ fun onComplete(result: T?, error: Throwable?)
9
+ }
10
+
11
+ class CoroutineCallback<T > @JvmOverloads constructor(
12
+ private val callback: Callback<T >,
13
+ override val context: CoroutineContext = Dispatchers.Default
14
+ ) : Continuation<T > {
15
+ override fun resumeWith(result: Result<T >) {
16
+ callback.onComplete(result.getOrNull(), result.exceptionOrNull())
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ package {{ sdk .namespace | caseDot }}.coroutines
2
+
3
+ import kotlinx.coroutines.Dispatchers
4
+ import kotlin.coroutines.Continuation
5
+ import kotlin.coroutines.CoroutineContext
6
+
7
+ interface Callback<T > {
8
+ fun onComplete(result: T?, error: Throwable?)
9
+ }
10
+
11
+ class CoroutineCallback<T > @JvmOverloads constructor(
12
+ private val callback: Callback<T >,
13
+ override val context: CoroutineContext = Dispatchers.Default
14
+ ) : Continuation<T > {
15
+ override fun resumeWith(result: Result<T >) {
16
+ callback.onComplete(result.getOrNull(), result.exceptionOrNull())
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments