Return Job
This commit is contained in:
parent
a5c0c23bae
commit
bd0fcce572
@ -18,6 +18,7 @@ package org.matrix.android.sdk.api.session
|
||||
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.lifecycle.LiveData
|
||||
import kotlinx.coroutines.Job
|
||||
import okhttp3.OkHttpClient
|
||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
import org.matrix.android.sdk.api.failure.GlobalError
|
||||
@ -279,5 +280,5 @@ interface Session :
|
||||
* Launch a coroutine using the session scope
|
||||
*/
|
||||
fun launch(context: CoroutineContext = EmptyCoroutineContext,
|
||||
block: suspend () -> Unit)
|
||||
block: suspend () -> Unit): Job
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.session
|
||||
import androidx.annotation.MainThread
|
||||
import dagger.Lazy
|
||||
import io.realm.RealmConfiguration
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.OkHttpClient
|
||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
@ -308,9 +309,9 @@ internal class DefaultSession @Inject constructor(
|
||||
}
|
||||
|
||||
override fun launch(context: CoroutineContext,
|
||||
block: suspend () -> Unit) {
|
||||
sessionCoroutineScopeHolder.scope?.launch(context) {
|
||||
block: suspend () -> Unit): Job {
|
||||
return sessionCoroutineScopeHolder.scope?.launch(context) {
|
||||
block()
|
||||
}
|
||||
} ?: throw IllegalStateException("Session is closed")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user