Skip to content

Commit

Permalink
Move Cookies persisting off the main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarta committed Jan 2, 2025
1 parent 4cb86cd commit 389cfcd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package dev.hotwire.navigation.observers
import android.webkit.CookieManager
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import dev.hotwire.navigation.util.dispatcherProvider
import kotlinx.coroutines.launch

internal class HotwireActivityObserver : DefaultLifecycleObserver {
/**
Expand All @@ -13,7 +16,9 @@ internal class HotwireActivityObserver : DefaultLifecycleObserver {
*/
override fun onStop(owner: LifecycleOwner) {
super.onStop(owner)
persistWebViewCookies()
owner.lifecycleScope.launch(dispatcherProvider.io) {
persistWebViewCookies()
}
}

private fun persistWebViewCookies() {
Expand Down

0 comments on commit 389cfcd

Please sign in to comment.