Solution for intro/part9
This commit is contained in:
@@ -72,7 +72,7 @@ login newViewer =
|
||||
Viewer.encode newViewer
|
||||
|> Encode.encode 0
|
||||
|> Just
|
||||
|> sendSessionToJavaScript
|
||||
|> storeSession
|
||||
|
||||
|
||||
|
||||
@@ -81,24 +81,10 @@ login newViewer =
|
||||
|
||||
logout : Cmd msg
|
||||
logout =
|
||||
sendSessionToJavaScript Nothing
|
||||
storeSession Nothing
|
||||
|
||||
|
||||
{-| 👉 TODO 1 of 2: Replace this do-nothing function with a port that sends the
|
||||
authentication token to JavaScript.
|
||||
|
||||
💡 HINT 1: When you convert it to a port, the port's name _must_ match
|
||||
the name JavaScript expects in `intro/server/public/index.html`.
|
||||
That name is not `sendSessionToJavaScript`, so you will need to
|
||||
rename it to match what JS expects!
|
||||
|
||||
💡 HINT 2: After you rename it, some code in this file will break because
|
||||
it was depending on the old name. Follow the compiler errors to fix them!
|
||||
|
||||
-}
|
||||
sendSessionToJavaScript : Maybe String -> Cmd msg
|
||||
sendSessionToJavaScript maybeAuthenticationToken =
|
||||
Cmd.none
|
||||
port storeSession : Maybe String -> Cmd msg
|
||||
|
||||
|
||||
|
||||
@@ -107,24 +93,10 @@ sendSessionToJavaScript maybeAuthenticationToken =
|
||||
|
||||
changes : (Session -> msg) -> Nav.Key -> Sub msg
|
||||
changes toMsg key =
|
||||
receiveSessionFromJavaScript (\val -> toMsg (decode key val))
|
||||
onSessionChange (\val -> toMsg (decode key val))
|
||||
|
||||
|
||||
{-| 👉 TODO 2 of 2: Replace this do-nothing function with a port that receives the
|
||||
authentication token from JavaScript.
|
||||
|
||||
💡 HINT 1: When you convert it to a port, the port's name _must_ match
|
||||
the name JavaScript expects in `intro/server/public/index.html`.
|
||||
That name is not `receiveSessionFromJavaScript`, so you will need to
|
||||
rename it to match what JS expects!
|
||||
|
||||
💡 HINT 2: After you rename it, some code in this file will break because
|
||||
it was depending on the old name. Follow the compiler errors to fix them!
|
||||
|
||||
-}
|
||||
receiveSessionFromJavaScript : (Value -> msg) -> Sub msg
|
||||
receiveSessionFromJavaScript toMsg =
|
||||
Sub.none
|
||||
port onSessionChange : (Value -> msg) -> Sub msg
|
||||
|
||||
|
||||
decode : Nav.Key -> Value -> Session
|
||||
|
||||
Reference in New Issue
Block a user