tricycle/system-actor-model/5.0.0

NOTE: the latest version is 9.0.0

Renamed to bellroy/system-actor-model. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as tricycle/system-actor-model still install under that name. 26 versions of 26 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/bellroy/system-actor-model.

What we checked: The repo moved to github.com/bellroy/system-actor-model. Rebuilt with git archive from commit c6fe8e0e50f3 of https://github.com/bellroy/system-actor-model (zip prefix tricycle-system-actor-model-4bb723d/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 16eb0c9fa4b2c4962edd809e3bce88be61ea9f93.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/tricycle/system-actor-model/zipball/5.0.0/

System.Component.Layout

Layout

A Layout is a component that can render other components.

Example usage

type alias Model =
    { instances : List System.Process.PID
    }


type MsgIn
    = AddProcess System.Process.PID
    | OnClickKillProcess System.Process.PID
    | ProcessKilled System.Process.PID


type MsgOut
    = KillProcess System.Process.PID


component : Layout Model MsgIn MsgOut layoutChildMsgs
component =
    { init =
        \_ ->
            ( { instances = [] }
            , []
            , Cmd.none
            )
    , update =
        \msgIn model ->
            case msgIn of
                AddProcess pid ->
                    ( { model
                        | instances = pid :: model.instances
                      }
                    , []
                    , Cmd.none
                    )


                OnClickKillProcess pid ->
                    ( model
                    , [ KillProcess pid ]
                    , Cmd.none
                    )


                ProcessKilled pid ->
                    ( { model
                        | instances = List.filter (not << System.Process.equals pid)
                      }
                    , []
                    , Cmd.none
                    )
    , view =
        \toSelf model renderPid ->
            model.instances
                |> List.map
                    (\pid ->
                        Html.div []
                            [ Html.button [ Html.Events.onClick (OnClickKillProcess pid) ] [ Html.text "kill process" ]
                                |> Html.map toSelf
                            , renderPid pid
                            ]
                    )
                |> Html.div []
    , subscriptions = always Sub.none
    , events = System.Event.ignoreAll
    }

Types

type alias Layout componentModel componentMsgIn componentMsgOut layoutChildMsgs =
{ init :
( PID, Value )
-> ( componentModel, List componentMsgOut, Cmd componentMsgIn )
, update :
componentMsgIn
-> componentModel
-> ( componentModel, List componentMsgOut, Cmd componentMsgIn )
, subscriptions : componentModel -> Sub componentMsgIn
, events : ComponentEventHandlers componentMsgIn
, view :
(componentMsgIn -> layoutChildMsgs)
-> componentModel
-> (PID -> Html layoutChildMsgs)
-> Html layoutChildMsgs
}

The Type of a Layout Component

Creation

Layout
componentModel
componentMsgIn
componentMsgOut
(SystemMessage address actorName appMsg)
-> { wrapModel : componentModel -> applicationModel
, wrapMsg : componentMsgIn -> appMsg
, mapIn : appMsg -> Maybe componentMsgIn
, mapOut :
PID -> componentMsgOut -> SystemMessage address actorName appMsg
}
-> Actor
componentModel
applicationModel
(Html (SystemMessage address actorName appMsg))
(SystemMessage address actorName appMsg)

Create an Actor from a Layout Component