Pebble.Companion.Platform
Companion platform subscription wiring.
Each platform API exposes a real Sub msg subscription. Compose them with plain Sub.batch instead of a special batch combinator.
import Pebble.Companion.Battery as Battery
import Pebble.Companion.Locale as Locale
import Pebble.Companion.Phone as Phone
init _ =
( model, Cmd.batch [ Battery.setup, Battery.current GotBattery ] )
subscriptions _ =
Sub.batch
[ Phone.onWatchToPhone FromWatch
, Battery.onBattery GotBattery
, Locale.onLocale GotLocale
]Union Types
Interest
type InterestBridge interest metadata for a platform API incoming stream.
Handler
type Handler msgIncoming platform event handler for a dedicated port subscription.
Commands
setup
setup : Interest -> Cmd msgRegister bridge interest with the companion bridge.
Pair this with the matching subscription from typed platform modules such as Battery.onBattery or Calendar.onCalendar.
Subscriptions
subscribe
subscribe : Handler msg -> Sub msgRegister bridge interest and subscribe to the API's dedicated incoming port.
Call the matching setup command from init so the bridge can route events to this handler.
Values
handler
handler : Interest -> (Decode.Value -> Result String a) -> (Result String a -> msg) -> Handler msgBuild a platform handler from interest metadata and decoders.
interest
interest : { id : String
, subscribeCommand : Maybe CommandEnvelope
, eventPrefixes : List String
, resultIdPrefixes : List String
}
-> InterestDescribe a platform API bridge interest.