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

refactor(elm): DRY out the main update code #219

Open
mrapacz opened this issue Mar 17, 2018 · 0 comments
Open

refactor(elm): DRY out the main update code #219

mrapacz opened this issue Mar 17, 2018 · 0 comments
Labels
Milestone

Comments

@mrapacz
Copy link
Collaborator

mrapacz commented Mar 17, 2018

Type

Refactor

Current behaviour
Our code gets quite repetitive

      MkUserMsg subMsg ->
            if User.Api.unauthorized subMsg then
                update (MkUserMsg Logout) model
            else
                let
                    ( updatedModel, cmd ) =
                        User.Update.update subMsg model.userData
                in
                    { model | userData = updatedModel } ! [ Cmd.map MkUserMsg cmd ]

      MkRankingMsg subMsg ->
            if Ranking.Api.unauthorized subMsg then
                update (MkUserMsg Logout) model
            else
                let
                    ( updatedModel, cmd ) =
                        Ranking.Update.update subMsg model.rankingData
                in
                    { model | rankingData = updatedModel } ! [ Cmd.map MkRankingMsg cmd ]

Expected behaviour
I think we could and we should make this flow more generic.

Motivation / use case
refactor

@mrapacz mrapacz added this to the Elm refactor milestone Mar 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant