61 lines
947 B
Elm
61 lines
947 B
Elm
module Global exposing
|
|
( Flags
|
|
, Model
|
|
, Msg(..)
|
|
, init
|
|
, subscriptions
|
|
, update
|
|
)
|
|
|
|
import Generated.Routes as Routes exposing (Route)
|
|
import Ports
|
|
|
|
|
|
type alias Flags =
|
|
()
|
|
|
|
|
|
type alias Model =
|
|
{ token : Maybe String
|
|
}
|
|
|
|
|
|
type Msg
|
|
= SignIn String
|
|
| SignOut
|
|
|
|
|
|
type alias Commands msg =
|
|
{ navigate : Route -> Cmd msg
|
|
}
|
|
|
|
|
|
init : Commands msg -> Flags -> ( Model, Cmd Msg, Cmd msg )
|
|
init _ _ =
|
|
( { token = Nothing
|
|
}
|
|
, Cmd.none
|
|
, Ports.log "Hello!"
|
|
)
|
|
|
|
|
|
update : Commands msg -> Msg -> Model -> ( Model, Cmd Msg, Cmd msg )
|
|
update _ msg model =
|
|
case msg of
|
|
SignIn token ->
|
|
( { model | token = Just token }
|
|
, Cmd.none
|
|
, Cmd.none
|
|
)
|
|
|
|
SignOut ->
|
|
( { model | token = Nothing }
|
|
, Cmd.none
|
|
, Cmd.none
|
|
)
|
|
|
|
|
|
subscriptions : Model -> Sub Msg
|
|
subscriptions _ =
|
|
Sub.none
|