noredink-ui/styleguide-app/Update.elm
2018-02-12 13:32:38 -08:00

38 lines
897 B
Elm

module Update exposing (Msg(..), subscriptions, update)
import Model exposing (..)
import NriModules as NriModules
import Routes as Routes exposing (Route)
type Msg
= UpdateModuleStates NriModules.Msg
| UrlChanged Route
| 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
)
UrlChanged route ->
( { model | route = route }
, Cmd.none
)
NoOp ->
( model, Cmd.none )
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.map UpdateModuleStates (NriModules.subscriptions model.moduleStates)