You might also want to check out Cmd.Extra (shmookey/cmd-extra), which has 
a function just for this:

  message : msg -> Cmd msg

Docs are available at 
http://package.elm-lang.org/packages/shmookey/cmd-extra/1.0.0/

Cheers,
Luke


On Thursday, June 23, 2016 at 4:18:37 PM UTC+10, Juan Martin Buireo wrote:
>
> 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.

Reply via email to