@@ -6,12 +6,9 @@ import com.adamratzman.spotify.http.HttpRequestMethod
6
6
import com.adamratzman.spotify.models.SpotifyAuthenticationException
7
7
import com.adamratzman.spotify.models.Token
8
8
import com.adamratzman.spotify.models.serialization.toObject
9
- import kotlinx.coroutines.Dispatchers
10
9
import kotlinx.coroutines.GlobalScope
11
10
import kotlinx.coroutines.Job
12
- import kotlinx.coroutines.coroutineScope
13
11
import kotlinx.coroutines.launch
14
- import kotlinx.coroutines.withContext
15
12
16
13
// Kotlin DSL builders
17
14
@@ -214,7 +211,7 @@ interface ISpotifyClientApiBuilder : ISpotifyApiBuilder {
214
211
*
215
212
* Provide a consumer object to be executed after the client has been successfully built
216
213
*/
217
- suspend fun buildAsync (consumer : (SpotifyClientApi ) -> Unit )
214
+ suspend fun buildAsync (consumer : (SpotifyClientApi ) -> Unit ): Job
218
215
219
216
/* *
220
217
* Create a Spotify authorization URL from which API access can be obtained
@@ -313,8 +310,8 @@ class SpotifyClientApiBuilder(
313
310
}
314
311
}
315
312
316
- override suspend fun buildAsync (consumer : (SpotifyClientApi ) -> Unit ) = coroutineScope {
317
- withContext( Dispatchers . Default ) { consumer(build()) }
313
+ override suspend fun buildAsync (consumer : (SpotifyClientApi ) -> Unit ) = GlobalScope .launch {
314
+ consumer(build())
318
315
}
319
316
}
320
317
@@ -348,7 +345,7 @@ class SpotifyAppApiBuilder(
348
345
* Provide a consumer object to be executed after the api has been successfully built
349
346
*/
350
347
override fun buildAsync (consumer : (SpotifyApi ) -> Unit ) = GlobalScope .launch {
351
- withContext( Dispatchers . Default ) { consumer(build()) }
348
+ consumer(build())
352
349
}
353
350
354
351
/* *
0 commit comments