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

Make all routes "refreshable" #82

Merged
merged 3 commits into from
Sep 14, 2017
Merged

Make all routes "refreshable" #82

merged 3 commits into from
Sep 14, 2017

Conversation

joshuaclayton
Copy link
Contributor

@joshuaclayton joshuaclayton commented Sep 11, 2017

What?

This updates routing to fire off any side-effects when the initial model is
loaded and we've parsed the URL, so any data necessary for the page is loaded
appropriately.

This doesn't allow for navigating forwards and backwards yet, however; there's
an issue currently with "refreshing" resolution after a new target is selected
that will need to be handled for that to work correctly. However, this improves
existing functionality and lays the foundation for additional extension.

This is a step towards resolution of #56.

Copy link

@JoelQ JoelQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would have preferred to see each of these commits as its own PR. The introduction of the Token type in particular stands on its own but adds a lot of noise when trying to see what the routing changes were.

termsEncoder terms =
list <| List.map (\t -> string t) terms
termsEncoder =
list << List.map string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup of the lambda

map2 (,) statsDecoder errors


notStartedDecoder : Decoder ( Stats, Errors )
notStartedDecoder =
map2 (,) (null NotStarted) (succeed Nothing)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the Errors type an alias for Maybe ? 😖

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This decoder confuses me. It's two constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, type alias Errors = Maybe (List Error). I decided not to tackle the modeling of that here.

This decoder is used when the response returns null, and yes, it's a tuple of stats (NotStarted, which is a nullary data constructor) and Nothing (since there are no errors).

@@ -107,7 +109,7 @@ updateResolver : RM.Msg -> Model -> ( Model, Cmd Msg )
updateResolver msg model =
let
token =
Maybe.withDefault "" <| currentToken model
Maybe.withDefault (Token.fromString "") <| currentToken model
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is an empty token even a thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, but I wanted to avoid the larger refactor here (basically, we'd align the messages and routes in a way where we're guaranteed a token).

startResolution token

_ ->
Cmd.none
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A case inside a let inside a case 😬 . Thoughts on extracting some functions?

@joshuaclayton joshuaclayton force-pushed the jc-improve-routing branch 2 times, most recently from 3b2870c to a5a174d Compare September 11, 2017 19:45
What?
=====

This looks at the current resolver status and, if the resolution hasn't
started, starts it.
@joshuaclayton joshuaclayton merged commit a9917c6 into master Sep 14, 2017
@joshuaclayton joshuaclayton deleted the jc-improve-routing branch September 14, 2017 17:17
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

Successfully merging this pull request may close these issues.

2 participants