Commit eca39c2
authored
refactor!: redesign Geolocation as static utility with watcher handle (#24279)
Redesigns the Geolocation API as a static utility class with a watcher
handle, replacing the previous per-UI facade.
*API surface*
Geolocation.getPosition() and Geolocation.watchPosition() are static. UI
is implicit (UI.getCurrent()), with explicit-UI overloads for background
threads. watchPosition() returns a GeolocationWatcher handle that
exposes both a callback API (addPositionListener) and a reactive
Signal<GeolocationResult>.
The owner component drives the watcher's lifecycle: watchPosition()
accepts an unattached owner and starts the underlying browser watch on
first attach (so it's safe from a view constructor); the watch
auto-stops on detach; stop() and resume() work explicitly. Per-UI state
(the GeolocationClient and the availability signal) lives in
UIInternals; static methods resolve the client there or install a
default one through the GeolocationClientFactory Lookup SPI.
options is now a non-null parameter — callers who want browser defaults
use the no-options overloads, or pass an empty GeolocationOptions
explicitly. The fields inside GeolocationOptions remain independently
optional.
*Error model*
Callback exceptions thrown from onSuccess/onError in getPosition and
from watcher position listeners are routed to
VaadinSession.getErrorHandler() instead of being silently swallowed by
CompletableFuture.whenComplete or aborting the listener loop.
GeolocationError.message() is renamed to debugInfo() to make it clear
the value is a free-form, non-localised string suitable for logs and bug
reports — not for UI display.
*Test seam*
GeolocationClient and WatchHandle become public so external test drivers
and native bridges can replace the production client through Lookup.
GeolocationOutcome becomes package-private since the public API no
longer exposes it. The watcher's bridge-failure error path is unchanged.1 parent 09ccde4 commit eca39c2
18 files changed
Lines changed: 801 additions & 747 deletions
File tree
- flow-server/src
- main/java/com/vaadin/flow/component
- geolocation
- internal
- test/java/com/vaadin/flow/component/geolocation
- flow-tests/test-root-context/src
- main/java/com/vaadin/flow/uitest/ui
- test/java/com/vaadin/flow/uitest/ui
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
| |||
Lines changed: 0 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
136 | 135 | | |
137 | 136 | | |
138 | 137 | | |
139 | | - | |
140 | | - | |
141 | 138 | | |
142 | 139 | | |
143 | 140 | | |
| |||
168 | 165 | | |
169 | 166 | | |
170 | 167 | | |
171 | | - | |
172 | 168 | | |
173 | 169 | | |
174 | 170 | | |
| |||
951 | 947 | | |
952 | 948 | | |
953 | 949 | | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | | - | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | 950 | | |
965 | 951 | | |
966 | 952 | | |
| |||
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
| 101 | + | |
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
| |||
154 | 153 | | |
155 | 154 | | |
156 | 155 | | |
157 | | - | |
158 | | - | |
| 156 | + | |
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
| |||
0 commit comments