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 msgRequest 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 msgRequest a bounded list of upcoming calendar events.
setup
setup : Cmd msgRegister the calendar push platform handler with the companion bridge.
setupCurrent
setupCurrent : Cmd msgRegister the calendar current-event platform handler with the companion bridge.
setupUpcoming
setupUpcoming : Cmd msgRegister the calendar upcoming-events platform handler with the companion bridge.
Subscriptions
onCalendar
onCalendar : (Result String (List CalendarEvent) -> msg) -> Sub msgReceive 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 msgReceive next-event command responses on the dedicated calendar port.
onUpcoming
onUpcoming : (Result String (List CalendarEvent) -> msg) -> Sub msgReceive upcoming-events command responses on the dedicated calendar port.