mcharmas/Android-ReactiveLocation

Request numUpdates isn't respected

Closed this issue · 2 comments

Following code somehow yields 2 onNext events with same coordinates on the start of the app:

private fun getFineLocation(): Observable<Location> {
        if (!isLocationEnabled()) {
            return Observable.empty()
        }

        val request = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
                .setExpirationDuration(LOCATION_TIMEOUT)
                .setNumUpdates(1)
        return reactiveLocationProvider.getUpdatedLocation(request)
                .subscribeOn(schedulers.loopedIo)
                .timeout(LOCATION_TIMEOUT,
                         TimeUnit.MILLISECONDS,
                         Observable.error(NetworkLocationTimeoutException()), schedulers.mainThread)
                .first()
    }

@mcharmas Do you have any input on this?
I have a not nice looking bug in the app because of that and it's live in the store, would love to fix it finally

I'll limit a stream with .take() operator based on passed LocationRequest in the next release.