noredink-ui/styleguide-app/Update.elm

43 lines
995 B
Elm
Raw Normal View History

2018-02-13 00:32:38 +03:00
module Update exposing (Msg(..), subscriptions, update)
import Browser
2018-02-13 00:32:38 +03:00
import Model exposing (..)
import NriModules as NriModules
import Url exposing (Url)
2018-02-13 00:32:38 +03:00
type Msg
= UpdateModuleStates NriModules.Msg
| OnUrlRequest Browser.UrlRequest
| OnUrlChange Url
2018-02-13 00:32:38 +03:00
| NoOp
update : Msg -> Model -> ( Model, Cmd Msg )
update action model =
case action of
UpdateModuleStates msg ->
let
( moduleStates, cmd ) =
NriModules.update msg model.moduleStates
in
( { model | moduleStates = moduleStates }
, Cmd.map UpdateModuleStates cmd
)
OnUrlRequest request ->
-- TODO
( model, Cmd.none )
OnUrlChange route ->
-- TODO
( model, Cmd.none )
2018-02-13 00:32:38 +03:00
NoOp ->
( model, Cmd.none )
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.map UpdateModuleStates (NriModules.subscriptions model.moduleStates)