An example add/multiply funnel, with a simulator.
AddMessage
and MultiplyMessage
go out from Elm to the JS.
SumMessage
and ProductMessage
come back in.
A MessageResponse
encapsulates a message.
NoResponse
is currently unused, but many PortFunnel-aware modules will need it.
List Message
Our internal state.
Just tracks all incoming messages.
PortFunnel.FunnelSpec
moduleName : String
The name of this module: "AddXY".
moduleDesc : PortFunnel.ModuleDesc Message State Response
Our module descriptor.
commander : (PortFunnel.GenericMessage -> Platform.Cmd.Cmd msg) -> Response -> Platform.Cmd.Cmd msg
Responsible for sending a CmdResponse
back througt the port.
Called by PortFunnel.appProcess
for each response returned by process
.
The AddXY
module doesn't send itself messages, so this is just PortFunnel.emptyCommander
.
State
initialState : State
The initial, empty state, so the application can initialize its state.
Message
out the Cmd
PortmakeAddMessage : Basics.Int -> Basics.Int -> Message
Make an AddMessage
makeMultiplyMessage : Basics.Int -> Basics.Int -> Message
Make a MultiplyMessage
send : (Json.Encode.Value -> Platform.Cmd.Cmd msg) -> Message -> Platform.Cmd.Cmd msg
Send a Message
through a Cmd
port.
toString : Message -> String
Convert a Message
to a nice-looking human-readable string.
toJsonString : Message -> String
Convert a Message
to the same JSON string that gets sent
over the wire to the JS code.
makeSimulatedCmdPort : (Json.Encode.Value -> msg) -> Json.Encode.Value -> Platform.Cmd.Cmd msg
Make a simulated Cmd
port.
stateToStrings : State -> List String
Convert our State
to a list of strings.