Hi guys,
If I have several components that they have its update functions and actions (Msg), How I can manage them from a single place?, I guess that I need a single update in main file and from here call all updates functions.
Per example, if I have this:
type Msg = NoOp | Move Int | SuccessMove Model | FailMove Http.Error
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
Move cardinal ->
(model, getNewPositions cardinal) -- Getnewsposition return info for the movement
NoOp ->
(model, Cmd.none)
SuccessMove newModel ->
-- TODO
FailMove error ->
(model, Cmd.none)
--------------------------------------------------
and in the main file I have this:
type Msg =
NoOp
| GoTo Int
update : Msg -> Model -> (Model, Cmd.Msg)
update msg model =
case msg of
NoOp ->
(model, Cmd.none)
GoTo a ->
let
model' =
-- How can I call the update from file here? (the type 'a' is the cardinal)
in
(model', Cmd.none)
In summary, I need a way to manage other updates from a main update.
Greetings!