[solved] Where there any changes to callback flow ...
# coroutines
a
[solved] Where there any changes to callback flow in Kotlin 1.5? The following code stopped working after upgrading to 1.5.10:
Copy code
private fun FusedLocationProviderClient.locationFlow(
    request: LocationRequest
) = callbackFlow<Location> {
    val callback = object : LocationCallback() {
        override fun onLocationResult(result: LocationResult?) {
            Log.e("Got result", "$result")
            result ?: return
            try {
                offer(result.lastLocation)
            } catch (e: Exception) {
                // swallow
            }
        }
    }

    requestLocationUpdates(
        request,
        callback,
        Looper.getMainLooper()
    ).addOnFailureListener { e ->
        close(e) // in case of exception, close the Flow
    }

    // clean up when Flow collection ends
    awaitClose {
        removeLocationUpdates(callback)
    }
}
Seems to have solved itself