Primitives / foldkit-primitives/device

Geolocation

const · packages/primitives/src/device/geolocation.ts:88

Argsnone
Model{ status: "unknown" | "ready" | "denied", coords: Option.Option<{ readonly latitude: number; readonly longitude: number; readonly accuracy: number; }>, lastError: Option.Option<string> }
MessagesFailed { message: string }, Located { latitude: number, longitude: number, accuracy: number }, Denied
Its full type
const Geolocation: Bundle.Bundle<
  'Geolocation',
  void,
  {
    readonly status: 'unknown' | 'ready' | 'denied'
    readonly coords: Option.Option<{
      readonly latitude: number
      readonly longitude: number
      readonly accuracy: number
    }>
    readonly lastError: Option.Option<string>
  },
  | { readonly _tag: 'Failed'; readonly message: string }
  | {
      readonly _tag: 'Located'
      readonly latitude: number
      readonly longitude: number
      readonly accuracy: number
    }
  | { readonly _tag: 'Denied' },
  never,
  never,
  never,
  NoView,
  {},
  {},
  undefined
>

Geolocation as a bundle: the device position in the Model, watched while placed. Permission denial is its own status (actionable UI); transient failures keep the last fix and note the error. No geolocation API yields an empty stream instead of throwing.

In the guides