effect-io-ai

Package: @effect/platform-browser
Module: Geolocation

Geolocation.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

Signature

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>
}

Source

Since v4.0.0