Add Logout Effect.

This commit is contained in:
Dillon Kearns 2022-04-09 08:10:45 -07:00
parent 8cbe96e6b8
commit 042dddf764

View File

@ -11,6 +11,7 @@ type Effect msg
| Cmd (Cmd msg)
| Batch (List (Effect msg))
| GetStargazers (Result Http.Error Int -> msg)
| Logout msg
| FetchPageData
{ body : Maybe { contentType : String, body : String }
, path : Maybe String
@ -61,6 +62,9 @@ map fn effect =
, toMsg = fetchInfo.toMsg >> fn
}
Logout msg ->
Logout (fn msg)
perform :
{ fetchRouteData :
@ -87,6 +91,17 @@ perform ({ fetchRouteData, fromPageMsg } as info) effect =
Batch list ->
Cmd.batch (List.map (perform info) list)
Logout toMsg ->
fetchRouteData
{ body =
Just
{ contentType = "application/json"
, body = ""
}
, path = Just "/logout"
, toMsg = \_ -> toMsg
}
GetStargazers toMsg ->
Http.get
{ url = "https://api.github.com/repos/dillonkearns/elm-pages"