webbhuset/elm-actor-model/3.0.0

NOTE: the latest version is 4.0.0

Webbhuset.Component.SystemEvent

System Events

= PIDNotFound PID
| Kill

System Event

System events are sent to a component's onSystem function.

onSystem : SystemEvent -> SystemEvent.Handling MsgIn
onSystem event =
    case event of
        PIDNotFound pid ->
            UnObserveData pid
                |> SystemEvent.iWillHandleIt


        Kill ->
            SystemEvent.default

This gives you the choice of how to handle them by returning Handling.

If you don't care you can just set the handling to default in your component's record.

component =
    { init = init
    , onSystem = always SystemEvent.default
    ...
    }

PIDNotFound

If your component sends a message to a PID that does not exist anymore you will receive a PIDNotFound event containing the PID of the killed process. This lets you clean up any PID's you stored in your model for example.

Default handling for this event is to do nothing.

Kill

Kill is received when your component is going to be killed. You have the chance to say some last words before dying.

Default handling for Kill is to also kill all the children of the process.

Handling

type alias Handling msgIn =
Handling msgIn

How should events be handeled.

default : Handling msgIn

Use event default handling.

doNothing : Handling msgIn

Don't do anyting.

iWillHandleIt : msgIn -> Handling msgIn

Handle it yourself.

mapHandling : (msg1 -> msg2) -> Handling msg1 -> Handling msg2

Map the Handling type.