mirror of
https://github.com/fluencelabs/dashboard
synced 2025-06-03 10:01:29 +00:00
32 lines
606 B
Elm
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 }
|