Interface GeolocationState
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
GeolocationError,GeolocationPosition,GeolocationState.Pending
public sealed interface GeolocationState
extends Serializable
permits GeolocationState.Pending, GeolocationPosition, GeolocationError
Represents the state of a geolocation tracking request.
Three states are possible:
GeolocationState.Pending— initial state before the browser respondsGeolocationPosition— a successful position fixGeolocationError— the browser reported an error
The sealed type enables exhaustive pattern matching:
switch (geo.state().get()) {
case GeolocationState.Pending p -> {
}
case GeolocationPosition pos -> map.setCenter(pos.coords());
case GeolocationError err -> showError(err.message());
}
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordInitial state before the browser has responded to the tracking request.