Package: @effect/platform-browser
Module: Geolocation
Defines the service interface for browser geolocation, providing effects for the current position and streams of watched positions.
When to use
Use when browser code needs a typed Effect service for one-shot location reads or streamed location updates.
Details
getCurrentPosition returns one position effect. watchPosition returns a
stream and accepts the browser PositionOptions plus an optional sliding
bufferSize.
Gotchas
Browser permission prompts, denied permissions, timeouts, unavailable
position data, secure-context restrictions, and policy restrictions are
surfaced as GeolocationError.
See
GeolocationError for represented browser geolocation failureslayer for the browser-backed service implementationSignature
export interface Geolocation {
readonly [TypeId]: typeof TypeId
readonly getCurrentPosition: (
options?: PositionOptions | undefined
) => Effect.Effect<GeolocationPosition, GeolocationError>
readonly watchPosition: (
options?:
| PositionOptions & {
readonly bufferSize?: number | undefined
}
| undefined
) => Stream.Stream<GeolocationPosition, GeolocationError>
}
Since v4.0.0