Making new Cmds

152 views
Skip to first unread message

Wil C

unread,
May 24, 2016, 12:44:26 PM5/24/16
to Elm Discuss
It's just an aside, in case someone searches for it. Here's how to make new commands:

Cmd.map (\_ -> NewMsg) Cmd.none

It wasn't obvious to me.

Wil

Janis Voigtländer

unread,
May 24, 2016, 1:48:33 PM5/24/16
to elm-d...@googlegroups.com

This is not doing what you almost certainly think it does.


--
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 elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wil C

unread,
May 25, 2016, 2:53:15 AM5/25/16
to Elm Discuss
It turns out it doesn't. What's the correct way to do this?

Wil

Peter Damoc

unread,
May 25, 2016, 2:59:29 AM5/25/16
to Elm Discuss

succeed : Msg -> Cmd Msg
succeed msg =
    Task.perform never (Task.succeed msg) 


with `never` from elm-community/basics-extra



--
There is NO FATE, we are the creators.
blog: http://damoc.ro/

Janis Voigtländer

unread,
May 25, 2016, 3:00:48 AM5/25/16
to elm-d...@googlegroups.com

Task.perform never identity (Task.succeed NewMsg)

with never from http://package.elm-lang.org/packages/elm-community/basics-extra

Wil C

unread,
May 25, 2016, 3:37:19 AM5/25/16
to Elm Discuss
That worked, thanks. I guess I should hold off telling people stuff.

Wil

Peter Damoc

unread,
May 25, 2016, 3:44:04 AM5/25/16
to Elm Discuss
Neah, keep doing that. 

You'll make mistakes but this is how we all learn. 
For example, my suggestion was broken because I forgot to put the `identity` as the second parameter :) 
I make tons of mistakes but I also learn a lot. 


Reply all
Reply to author
Forward
0 new messages