Clean up part10
This commit is contained in:
@@ -37,8 +37,7 @@ subscriptions model =
|
|||||||
case model of
|
case model of
|
||||||
Home pageModel ->
|
Home pageModel ->
|
||||||
-- TODO use Sub.map to translate from Page.Home.subscriptions
|
-- TODO use Sub.map to translate from Page.Home.subscriptions
|
||||||
Page.Home.subscriptions pageModel
|
Sub.none
|
||||||
|> Sub.map HomeMsg
|
|
||||||
|
|
||||||
Repository pageModel ->
|
Repository pageModel ->
|
||||||
-- Repository has no subscriptions, so there's nothing to translate!
|
-- Repository has no subscriptions, so there's nothing to translate!
|
||||||
@@ -54,13 +53,11 @@ init result =
|
|||||||
case result of
|
case result of
|
||||||
Ok (Page.Home) ->
|
Ok (Page.Home) ->
|
||||||
-- TODO use Html.map to translate from Page.Home.view
|
-- TODO use Html.map to translate from Page.Home.view
|
||||||
Page.Home.init
|
( NotFound, Cmd.none )
|
||||||
|> Tuple2.mapEach Home (Cmd.map HomeMsg)
|
|
||||||
|
|
||||||
Ok (Page.Repository repoOwner repoName) ->
|
Ok (Page.Repository repoOwner repoName) ->
|
||||||
-- TODO use Html.map to translate from Page.Repository.view
|
-- TODO use Html.map to translate from Page.Repository.view
|
||||||
Page.Repository.init repoOwner repoName
|
( NotFound, Cmd.none )
|
||||||
|> Tuple2.mapEach Repository (Cmd.map RepositoryMsg)
|
|
||||||
|
|
||||||
Ok (Page.NotFound) ->
|
Ok (Page.NotFound) ->
|
||||||
( NotFound, Cmd.none )
|
( NotFound, Cmd.none )
|
||||||
@@ -75,13 +72,11 @@ view model =
|
|||||||
case model of
|
case model of
|
||||||
Home pageModel ->
|
Home pageModel ->
|
||||||
-- TODO use Html.map to translate from Page.Home.view
|
-- TODO use Html.map to translate from Page.Home.view
|
||||||
Page.Home.view pageModel
|
text "Nothing to see here yet. Still need to translate Home!"
|
||||||
|> Html.map HomeMsg
|
|
||||||
|
|
||||||
Repository pageModel ->
|
Repository pageModel ->
|
||||||
-- TODO use Html.map to translate from Page.Repository.view
|
-- TODO use Html.map to translate from Page.Repository.view
|
||||||
Page.Repository.view pageModel
|
text "Nothing to see here yet. Still need to translate Repository!"
|
||||||
|> Html.map RepositoryMsg
|
|
||||||
|
|
||||||
NotFound ->
|
NotFound ->
|
||||||
h1 [] [ text "Page Not Found" ]
|
h1 [] [ text "Page Not Found" ]
|
||||||
@@ -106,14 +101,12 @@ update msg model =
|
|||||||
-- to translate from Page.Home.update
|
-- to translate from Page.Home.update
|
||||||
--
|
--
|
||||||
-- mapEach : (a -> newA) -> (b -> newB) -> ( a, b ) -> ( newA, newB )
|
-- mapEach : (a -> newA) -> (b -> newB) -> ( a, b ) -> ( newA, newB )
|
||||||
Page.Home.update pageMsg pageModel
|
( model, Cmd.none )
|
||||||
|> Tuple2.mapEach Home (Cmd.map HomeMsg)
|
|
||||||
|
|
||||||
( RepositoryMsg pageMsg, Repository pageModel ) ->
|
( RepositoryMsg pageMsg, Repository pageModel ) ->
|
||||||
-- TODO use Tuple2.mapEach and (Cmd.map RepositoryMsg)
|
-- TODO use Tuple2.mapEach and (Cmd.map RepositoryMsg)
|
||||||
-- to translate from Page.Repository.update
|
-- to translate from Page.Repository.update
|
||||||
Page.Repository.update pageMsg pageModel
|
( model, Cmd.none )
|
||||||
|> Tuple2.mapEach Repository (Cmd.map RepositoryMsg)
|
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
( model, Cmd.none )
|
( model, Cmd.none )
|
||||||
@@ -127,16 +120,14 @@ urlUpdate result model =
|
|||||||
-- to translate from Page.Home.init
|
-- to translate from Page.Home.init
|
||||||
--
|
--
|
||||||
-- mapEach : (a -> newA) -> (b -> newB) -> ( a, b ) -> ( newA, newB )
|
-- mapEach : (a -> newA) -> (b -> newB) -> ( a, b ) -> ( newA, newB )
|
||||||
Page.Home.init
|
( model, Cmd.none )
|
||||||
|> Tuple2.mapEach Home (Cmd.map HomeMsg)
|
|
||||||
|
|
||||||
Ok (Page.Repository repoOwner repoName) ->
|
Ok (Page.Repository repoOwner repoName) ->
|
||||||
-- TODO use Tuple2.mapEach and (Cmd.map RepositoryMsg)
|
-- TODO use Tuple2.mapEach and (Cmd.map RepositoryMsg)
|
||||||
-- to translate from Page.Repository.init
|
-- to translate from Page.Repository.init
|
||||||
--
|
--
|
||||||
-- HINT: Page.Repository.init is a function that takes 2 arguments.
|
-- HINT: Page.Repository.init is a function that takes 2 arguments.
|
||||||
Page.Repository.init repoOwner repoName
|
( model, Cmd.none )
|
||||||
|> Tuple2.mapEach Repository (Cmd.map RepositoryMsg)
|
|
||||||
|
|
||||||
Ok (Page.NotFound) ->
|
Ok (Page.NotFound) ->
|
||||||
( NotFound, Cmd.none )
|
( NotFound, Cmd.none )
|
||||||
|
|||||||
@@ -21,11 +21,7 @@
|
|||||||
var app = Elm.Main.embed(document.getElementById("elm-landing-pad"));
|
var app = Elm.Main.embed(document.getElementById("elm-landing-pad"));
|
||||||
|
|
||||||
function searchGithub(query) {
|
function searchGithub(query) {
|
||||||
console.log("Searching for", query);
|
|
||||||
|
|
||||||
github.getSearch(query).repositories({}, function (err, repositories) {
|
github.getSearch(query).repositories({}, function (err, repositories) {
|
||||||
console.log("Got response", repositories);
|
|
||||||
|
|
||||||
app.ports.githubResponse.send(repositories);
|
app.ports.githubResponse.send(repositories);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user