2020-11-23 14:27:33 +03:00
|
|
|
port module Port exposing (..)
|
|
|
|
|
2020-11-23 15:44:45 +03:00
|
|
|
import Air exposing (Air(..))
|
2020-11-23 14:27:33 +03:00
|
|
|
import Dict exposing (Dict)
|
|
|
|
import Json.Encode exposing (Value)
|
2020-11-25 19:51:05 +03:00
|
|
|
import Services.Model exposing (Service)
|
2020-11-23 14:27:33 +03:00
|
|
|
|
|
|
|
|
2020-11-23 15:44:45 +03:00
|
|
|
type alias SendParticle =
|
|
|
|
{ script : String, data : Value }
|
2020-11-23 14:27:33 +03:00
|
|
|
|
|
|
|
|
2020-11-23 15:44:45 +03:00
|
|
|
type alias ReceiveEvent =
|
2020-11-25 19:51:05 +03:00
|
|
|
{ name : String, peer : String, peers : Maybe (List String), services : Maybe (List Service), modules : Maybe (List String) }
|
2020-11-23 14:27:33 +03:00
|
|
|
|
|
|
|
|
2020-11-23 15:44:45 +03:00
|
|
|
port sendParticle : SendParticle -> Cmd msg
|
|
|
|
|
|
|
|
|
|
|
|
port eventReceiver : (ReceiveEvent -> msg) -> Sub msg
|
|
|
|
|
|
|
|
|
|
|
|
port relayChanged : (String -> msg) -> Sub msg
|
|
|
|
|
|
|
|
|
|
|
|
sendAir : Air -> Cmd msg
|
2020-11-23 14:27:33 +03:00
|
|
|
sendAir (Air dataDict script) =
|
|
|
|
let
|
2020-11-23 15:44:45 +03:00
|
|
|
data =
|
|
|
|
Json.Encode.object <| Dict.toList dataDict
|
2020-11-23 14:27:33 +03:00
|
|
|
in
|
2020-11-23 15:44:45 +03:00
|
|
|
sendParticle { script = script, data = data }
|