Skip to content

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

Description

@mrapacz

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions