Pebble.Companion.Calendar

Calendar helpers for companion apps.

import Pebble.Companion.Calendar as Calendar

type Msg
    = GotCalendar (Result String (List Calendar.CalendarEvent))

init _ =
    ( model, Calendar.current (GotCalendar << Result.map maybeAsList) )

subscriptions _ =
    Calendar.onCalendar GotCalendar

maybeAsList event =
    case event of
        Nothing -> []
        Just value -> [ value ]

Types

CalendarEvent

type alias CalendarEvent =
    { id : String
    , title : String
    , location : Maybe String
    , startMillis : Int
    , endMillis : Int
    , allDay : Bool
    }

A calendar entry normalized for companion apps.

Commands

current

current : (Result String (Maybe CalendarEvent) -> msg) -> Cmd msg

Request the next calendar event, if available.

This registers the calendar bridge (via setup) before sending the request. Pair it with onCalendar in subscriptions so responses can reach your update.

upcoming

upcoming : Int -> (Result String (List CalendarEvent) -> msg) -> Cmd msg

Request a bounded list of upcoming calendar events.

setup

setup : Cmd msg

Register the calendar push platform handler with the companion bridge.

setupCurrent

setupCurrent : Cmd msg

Register the calendar current-event platform handler with the companion bridge.

setupUpcoming

setupUpcoming : Cmd msg

Register the calendar upcoming-events platform handler with the companion bridge.

Subscriptions

onCalendar

onCalendar : (Result String (List CalendarEvent) -> msg) -> Sub msg

Receive pushed calendar updates from the companion bridge.

Registering this subscription also tells the bridge to send calendar updates.

onCurrent

onCurrent : (Result String (Maybe CalendarEvent) -> msg) -> Sub msg

Receive next-event command responses on the dedicated calendar port.

onUpcoming

onUpcoming : (Result String (List CalendarEvent) -> msg) -> Sub msg

Receive upcoming-events command responses on the dedicated calendar port.