Have you read the “FAW for Learners” linked to from http://elm-lang.org/docs
?

This seems relevant to your question:
http://elm-community.github.io/elm-faq/17.html#how-do-i-generate-a-new-message-as-a-command
​

2016-06-23 8:18 GMT+02:00 Juan Martin Buireo <[email protected]>:

> Hi, I am developing a game in Elm 0.17. I am doing a memotest.
>
> I want to create my own Cmd.
>
> Here is what I want to do, I have in my:
>
> type Msg = FlipCard Int Card.Msg
>
> So every time I click on a card, this one calls that msg and flips the
> card.
> In my model, i have the List Card and GameState where
>
> type GameState = InProgress | Finished
>
> So, once all the cards are "found", I want the gameState to change to
> Finished. So I added a new Msg: ChangeGameState GameState
>
> So in my update function I do the following:
> update msg ({cards, gameState} as model) =
> case msg of
>         FlipCard id message -> ({ model | cards = checkCards (updateCards
> id message cards) }, HERE I WANT TO CALL ChangeGameState state ONCE IT
> FINISHEd)
>         ChangeGameState state -> ({ model | gameState = checkGameState
> cards }, Cmd.none)
>
> So, I want in the cmd of FlipCard to call the ChangeGameState state to
> check if the game is finished or not. If I do the checking of the gameState
> in the same line as FlipCard, my game is won once I click again on a card
> found. So I have to do it this way to make it work. But I dont know how to
> create my "own" CMD
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to