elm-return icon indicating copy to clipboard operation
elm-return copied to clipboard

Alternative to effect

Open DanielCardonaRojas opened this issue 7 years ago • 2 comments

effect is really nice but It would also be nice to have a helper function similar to effect but not depending on the model state itself and instead on any other value.

For instance the value arriving in a msg (route).

Navigate route ->
            Return.singleton { model | navigationMenu = Selection.select route model.navigationMenu }
            |> Return.command (Route.modify route)
            |> Return.command
                (if route == LoginRoute then
                    Session.store <| Session.session Nothing
                else
                    Cmd.none
                )

So maybe a helper function would allow to clean those if statements a bit, something like:

Return.commandWhen : Bool -> Cmd msg -> Return msg mdl

DanielCardonaRojas avatar Jun 27 '18 16:06 DanielCardonaRojas

This sounds similar guard from MonadPlus...

toastal avatar Aug 08 '18 18:08 toastal

@DanielCardonaRojas can you open a PR with a concrete suggestion in code?

Fresheyeball avatar Aug 24 '18 21:08 Fresheyeball