Interface GeolocationResult

All Superinterfaces:
Serializable
All Known Implementing Classes:
GeolocationError, GeolocationPending, GeolocationPosition

public sealed interface GeolocationResult extends Serializable permits GeolocationPending, GeolocationPosition, GeolocationError
The outcome of a geolocation request — a successful reading, an error, or the initial "waiting for first reading" state of a tracker.

Passed to Geolocation.get(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.geolocation.GeolocationResult>) callbacks and held by the signal exposed by GeolocationTracker.value(). A GeolocationResult is always exactly one of three things:

The sealed interface is designed for exhaustive pattern matching. A switch covering all three permitted subtypes is guaranteed complete at compile time — adding a new variant in a future version of Flow would break existing switches so that callers are forced to decide how to handle it.

 switch (result) {
 case GeolocationPending p -> showSpinner();
 case GeolocationPosition pos -> map.setCenter(pos.coords());
 case GeolocationError err -> showError(err.message());
 }