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:

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 Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Initial state before the browser has responded to the tracking request.