bellroy/elm-actor-framework/1.0.0

Formerly tricycle/elm-actor-framework. Search finds this package by either name.

Framework.Actor

type alias Component appFlags componentModel componentMsgIn componentMsgOut output frameworkMsg =
{ init :
( Pid, appFlags )
-> ( componentModel, List componentMsgOut, Cmd componentMsgIn )
, update :
componentMsgIn
-> componentModel
-> ( componentModel, List componentMsgOut, Cmd componentMsgIn )
, subscriptions : componentModel -> Sub componentMsgIn
, view :
(componentMsgIn -> frameworkMsg)
-> componentModel
-> (Pid -> Maybe output)
-> output
}

Actor

type alias Actor appFlags componentModel appModel output frameworkMsg =
{ processMethods :
ProcessMethods componentModel appModel output frameworkMsg
, init : ( Pid, appFlags ) -> ( appModel, frameworkMsg )
, apply : componentModel -> Process appModel output frameworkMsg
}
{ toAppModel : componentModel -> appModel
, toAppMsg : componentMsgIn -> appMsg
, fromAppMsg : appMsg -> Maybe componentMsgIn
, onMsgOut :
{ self : Pid
, msgOut : componentMsgOut
}
-> FrameworkMessage
appFlags
appAddresses
appActors
appModel
appMsg
}
-> Component
appFlags
componentModel
componentMsgIn
componentMsgOut
output
(FrameworkMessage
appFlags
appAddresses
appActors
appModel
appMsg
)
-> Actor
appFlags
componentModel
appModel
output
(FrameworkMessage
appFlags
appAddresses
appActors
appModel
appMsg
)

Progress a Component into an Actor by supplying it functions of how to handle application types.

Process

type alias ProcessMethods componentModel appModel output frameworkMsg =
ProcessMethods componentModel appModel output frameworkMsg
type alias Process appModel output frameworkMsg =
Process appModel output frameworkMsg

An Actor that has been spawned inside the framework always receives an unique identifier (PID).

The PID also holds information about who spawned (started) the process.

Process Identifier

type alias Pid =
Pid

The type of a Pid

spawnedBy : Pid -> Pid

Retrieve the Pid responsible for spawning the given Pid

Component Utility

( ( ( Pid, a )
-> ( componentModel, List componentMsgOut, Cmd componentMsgIn )
)
-> ( Pid, appFlags )
-> ( componentModel, List componentMsgOut, Cmd componentMsgIn )
)
-> Component
a
componentModel
componentMsgIn
componentMsgOut
output
frameworkMsg
-> Component
appFlags
componentModel
componentMsgIn
componentMsgOut
output
frameworkMsg

Transform your components init function

( ( componentMsgIn
-> componentModel
-> ( componentModel, List componentMsgOut, Cmd componentMsgIn )
)
-> componentMsgIn
-> componentModel
-> ( componentModel, List componentMsgOut, Cmd componentMsgIn )
)
-> Component
appFlags
componentModel
componentMsgIn
componentMsgOut
output
frameworkMsg
-> Component
appFlags
componentModel
componentMsgIn
componentMsgOut
output
frameworkMsg

Transform your components update function

( (componentModel -> Sub componentMsgIn)
-> componentModel
-> Sub componentMsgIn
)
-> Component
appFlags
componentModel
componentMsgIn
componentMsgOut
output
frameworkMsg
-> Component
appFlags
componentModel
componentMsgIn
componentMsgOut
output
frameworkMsg

Transform your components subscriptions function

( ( (componentMsgIn -> frameworkMsg)
-> componentModel
-> (Pid -> Maybe outputA)
-> outputA
)
-> (componentMsgIn -> frameworkMsg)
-> componentModel
-> (Pid -> Maybe outputB)
-> outputB
)
-> Component
appFlags
componentModel
componentMsgIn
componentMsgOut
outputA
frameworkMsg
-> Component
appFlags
componentModel
componentMsgIn
componentMsgOut
outputB
frameworkMsg

Transform your components view function

Process Utility

pidSystem : Pid

The System's Pid

pidCompare : Pid -> Pid -> Order

Compare two Pid's

pidEquals : Pid -> Pid -> Bool

Check if two Pid's are in fact the same

pidToInt : Pid -> Int

Returns an Integer representation of a Pid.

pidToString : Pid -> String

Returns a String representation of a Pid.

unsafePidFromInt : Int -> Pid

Create a Pid from an Int, should only be used when writing tests