Interface GeolocationResult

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

public sealed interface GeolocationResult extends Serializable permits GeolocationOutcome, GeolocationPending
Anything a watcher can currently hold — a successful reading, an error, or the initial "waiting for first reading" state.

Held by the signal exposed by GeolocationWatcher.valueSignal(). A GeolocationResult is always exactly one of three things:

One-shot Geolocation.getPosition(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.geolocation.GeolocationPosition>, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.geolocation.GeolocationError>) requests never produce GeolocationPending; they deliver the position and the error through separate callbacks instead.

The sealed hierarchy is designed for exhaustive pattern matching. A switch covering the three permitted variants is guaranteed complete at compile time.

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