tricycle / system-actor-model / System.Actor

Actor

In the context of this package an Actor is a Component that is mapped to the System.

Currently there are three components defined;

An Actor probably looks very familiar to you, that is because it closely resembles the Elm Program definition.

It should be relativaly straight forwards to map you exisiting Elm component on top of one of the existing Components.

Actors can communicate with other Actors when they know their PIDs or they can send a message to other Actors listening on a given Address.

Actor

An Actor is an alias for the following Record


type alias Actor componentModel appModel output systemMsg =
{ init : ( System.Internal.PID.PID
, Json.Decode.Value ) -> ( appModel
, systemMsg )
, update : componentModel -> systemMsg -> System.Internal.PID.PID -> ( appModel
, systemMsg )
, subscriptions : componentModel -> System.Internal.PID.PID -> Platform.Sub.Sub systemMsg
, events : System.Internal.Event.Event -> System.Internal.PID.PID -> System.Event.EventHandler systemMsg
, view : Maybe (componentModel -> System.Internal.PID.PID -> (System.Internal.PID.PID -> Maybe output) -> output) 
}

An Actor looks a lot like a Browser.element!

It's quite easy to grab an existing Elm application and make it part of an application that is setup to use this package.

SystemActor


type alias SystemActor appModel output systemMsg =
System.Internal.SystemActor.SystemActor appModel output systemMsg

An Actor within the System has a different Type,

it no longer has the componentModel in the type definition, this is because the componentModel is no wrapped using the appModel.

You can create a SystemActor using the toSystemActor function.

toSystemActor : Actor componentModel appModel output systemMsg -> componentModel -> SystemActor appModel output systemMsg

Apply your model over your Actor and create a SystemActor