Defines the API for the ports that are required to interface with JS.
This is just an internal implementation, but exposed so the types are available via
the implementation of the ports in PhoenixPorts
(which must be installed via NPM). See README.md
for details.
This is the API that the ports module must implement.
{ channelMessage : (( Phoenix.Channel.Topic
, String
, Json.Encode.Value ) -> Phoenix.Internal.Types.Msg msg) -> Platform.Sub.Sub (Phoenix.Internal.Types.Msg msg)
, pushReply : (PushReply -> Phoenix.Internal.Types.Msg msg) -> Platform.Sub.Sub (Phoenix.Internal.Types.Msg msg)
, channelsCreated : (List ( Phoenix.Channel.Topic
, Phoenix.Internal.ChannelStates.ChannelObj ) -> Phoenix.Internal.Types.Msg msg) -> Platform.Sub.Sub (Phoenix.Internal.Types.Msg msg)
, channelError : (Phoenix.Channel.Topic -> Phoenix.Internal.Types.Msg msg) -> Platform.Sub.Sub (Phoenix.Internal.Types.Msg msg)
, socketOpened : (() -> Phoenix.Internal.Types.Msg msg) -> Platform.Sub.Sub (Phoenix.Internal.Types.Msg msg)
, socketClosed : (SocketCloseParams -> Phoenix.Internal.Types.Msg msg) -> Platform.Sub.Sub (Phoenix.Internal.Types.Msg msg)
, presenceUpdated : (PresenceUpdate -> Phoenix.Internal.Types.Msg msg) -> Platform.Sub.Sub (Phoenix.Internal.Types.Msg msg)
, connectSocket : ConnectParams -> Platform.Cmd.Cmd (Phoenix.Internal.Types.Msg msg)
, joinChannels : List JoinParams -> Platform.Cmd.Cmd (Phoenix.Internal.Types.Msg msg)
, leaveChannel : Phoenix.Internal.ChannelStates.ChannelObj -> Platform.Cmd.Cmd (Phoenix.Internal.Types.Msg msg)
, pushChannel : PushParams -> Platform.Cmd.Cmd (Phoenix.Internal.Types.Msg msg)
}
Functions that need to implemented by Ports
These types are used internally to communicate between Elm and the JS ports code.
( Phoenix.Channel.Topic
, Phoenix.Internal.Types.Event
, Json.Encode.Value
)
Message from a channel
{ onOk : Basics.Bool
, onError : Basics.Bool
, onTimeout : Basics.Bool
}
Handlers to invoke on a push
{ topic : Phoenix.Channel.Topic
, payload : Json.Encode.Value
, onHandlers : OnHandlers
, presence : Basics.Bool
}
Channel join params
{ ref : Basics.Int
, channel : Phoenix.Internal.ChannelStates.ChannelObj
, event : Phoenix.Internal.Types.Event
, payload : Json.Encode.Value
, onHandlers : OnHandlers
}
Push params
{ eventName : String
, topic : Phoenix.Channel.Topic
, pushType : String
, ref : Maybe Basics.Int
, payload : Json.Encode.Value
}
Push reply params
{ endpoint : String
, params : Json.Encode.Value
}
Socket connect params
{ code : Basics.Int
, reason : String
, wasClean : Basics.Bool
}
Socket closed params
{ eventName : String
, topic : Phoenix.Channel.Topic
, presences : List ( String
, List Json.Encode.Value )
}
Presence update reply params