Interface GeolocationClient
- All Superinterfaces:
Serializable
Framework-internal port between the
Geolocation static API and
whatever delivers actual position data — the browser in production, an
in-memory driver in browserless tests. Application code does not interact
with this interface; it is exposed so external test drivers can replace the
production client via
UIInternals.setGeolocationClient(GeolocationClient).
Threading: all callbacks on this interface (the future returned by
get(com.vaadin.flow.component.geolocation.GeolocationOptions), the onUpdate consumer passed to startWatch(com.vaadin.flow.component.Component, com.vaadin.flow.component.geolocation.GeolocationOptions, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.geolocation.GeolocationResult>),
and the onChange consumer passed to subscribeAvailability(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.geolocation.GeolocationAvailability>))
must be invoked on the UI thread.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceHandle to a watch session. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases any resources held by this client.Returns the most recently observed availability.CompletableFuture<com.vaadin.flow.component.geolocation.GeolocationOutcome> get(@Nullable GeolocationOptions options) Issues a one-shot position request.startWatch(Component owner, @Nullable GeolocationOptions options, SerializableConsumer<GeolocationResult> onUpdate) Starts a watch session bound toowner.Subscribes to availability changes.
-
Method Details
-
get
CompletableFuture<com.vaadin.flow.component.geolocation.GeolocationOutcome> get(@Nullable GeolocationOptions options) Issues a one-shot position request. The future completes once the client has an answer (a position or an error). -
startWatch
GeolocationClient.WatchHandle startWatch(Component owner, @Nullable GeolocationOptions options, SerializableConsumer<GeolocationResult> onUpdate) Starts a watch session bound toowner. Position and error pushes are delivered viaonUpdate. The returned handle is used to stop the watch and to query whether it is still active. -
subscribeAvailability
Subscribes to availability changes. The returned registration removes the subscription. -
currentAvailability
GeolocationAvailability currentAvailability()Returns the most recently observed availability. Implementations must seed an initial value at construction; the result is never null. -
close
void close()Releases any resources held by this client. Called when one client is being replaced by another (e.g. when a test driver is installed) and on UI detach. Idempotent: calling more than once is a no-op. Afterclose(), the behavior ofget(com.vaadin.flow.component.geolocation.GeolocationOptions)andstartWatch(com.vaadin.flow.component.Component, com.vaadin.flow.component.geolocation.GeolocationOptions, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.geolocation.GeolocationResult>)is undefined and callers must not invoke them.
-