dashboard/src/Port.elm
2020-11-23 15:44:45 +03:00

32 lines
606 B
Elm

port module Port exposing (..)
import Air exposing (Air(..))
import Dict exposing (Dict)
import Json.Encode exposing (Value)
type alias SendParticle =
{ script : String, data : Value }
type alias ReceiveEvent =
{ name : String, args : List Value }
port sendParticle : SendParticle -> Cmd msg
port eventReceiver : (ReceiveEvent -> msg) -> Sub msg
port relayChanged : (String -> msg) -> Sub msg
sendAir : Air -> Cmd msg
sendAir (Air dataDict script) =
let
data =
Json.Encode.object <| Dict.toList dataDict
in
sendParticle { script = script, data = data }