Skip to content

Commit 3d2c495

Browse files
committed
execute js delayed consumer, remove rest action blocking try/catch
1 parent 5238c97 commit 3d2c495

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/commonMain/kotlin/com.adamratzman.spotify/SpotifyRestAction.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import com.adamratzman.spotify.models.AbstractPagingObject
55
import com.adamratzman.spotify.utils.TimeUnit
66
import com.adamratzman.spotify.utils.getCurrentTimeMs
77
import com.adamratzman.spotify.utils.schedule
8-
import kotlin.coroutines.resume
9-
import kotlin.coroutines.resumeWithException
10-
import kotlin.coroutines.suspendCoroutine
118
import kotlinx.coroutines.CoroutineDispatcher
129
import kotlinx.coroutines.Dispatchers
1310
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -21,6 +18,9 @@ import kotlinx.coroutines.flow.flow
2118
import kotlinx.coroutines.flow.flowOn
2219
import kotlinx.coroutines.launch
2320
import kotlinx.coroutines.withContext
21+
import kotlin.coroutines.resume
22+
import kotlin.coroutines.resumeWithException
23+
import kotlin.coroutines.suspendCoroutine
2424

2525
/**
2626
* Provides a uniform interface to retrieve, whether synchronously or asynchronously, [T] from Spotify
@@ -46,11 +46,7 @@ open class SpotifyRestAction<T> internal constructor(protected val api: SpotifyA
4646
*/
4747
fun complete(): T {
4848
hasRunBacking = true
49-
return try {
50-
supplier().also { hasCompletedBacking = true }
51-
} catch (e: Throwable) {
52-
throw e
53-
}
49+
return supplier().also { hasCompletedBacking = true }
5450
}
5551

5652
/**

src/jsMain/kotlin/com/adamratzman/spotify/utils/Concurrency.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ internal actual fun CoroutineScope.schedule(
1818
) {
1919
launch {
2020
delay(timeUnit.toMillis(quantity.toLong()))
21+
consumer()
2122
}
2223
}

0 commit comments

Comments
 (0)