Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative to effect #11

Open
DanielCardonaRojas opened this issue Jun 27, 2018 · 2 comments
Open

Alternative to effect #11

DanielCardonaRojas opened this issue Jun 27, 2018 · 2 comments

Comments

@DanielCardonaRojas
Copy link

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

@toastal
Copy link
Contributor

toastal commented Aug 8, 2018

This sounds similar guard from MonadPlus...

@Fresheyeball
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants