now routing subscriptions
This commit is contained in:
parent
18714713b6
commit
83d8196261
|
@ -1,4 +1,4 @@
|
|||
module Body exposing (Msg(..), Model(..), init, update, view, handleRoute)
|
||||
module Body exposing (Msg(..), Model(..), init, update, view, handleRoute, subscriptions)
|
||||
|
||||
import Element
|
||||
|
||||
|
@ -28,6 +28,16 @@ type Model
|
|||
init : () -> Model
|
||||
init flags = ModelLanding (Page.Landing.init flags)
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions model =
|
||||
case model of
|
||||
ModelLanding m -> Page.Landing.subscriptions m |> Sub.map MsgLanding
|
||||
ModelProducts m -> Page.Products.subscriptions m |> Sub.map MsgProducts
|
||||
ModelResources m -> Page.Resources.subscriptions m |> Sub.map MsgResources
|
||||
ModelAbout m -> Page.About.subscriptions m |> Sub.map MsgAbout
|
||||
ModelContact m -> Page.Contact.subscriptions m |> Sub.map MsgContact
|
||||
ModelNotFound m -> Page.NotFound.subscriptions m |> Sub.map MsgNotFound
|
||||
|
||||
handleRoute : String -> Model
|
||||
handleRoute path =
|
||||
let
|
||||
|
@ -74,11 +84,11 @@ view : Model -> Element.Element Msg
|
|||
view model =
|
||||
let
|
||||
content = case model of
|
||||
ModelLanding m -> Page.Landing.view m |> Element.map MsgLanding
|
||||
ModelProducts m -> Page.Products.view m |> Element.map MsgProducts
|
||||
ModelResources m -> Page.Resources.view m |> Element.map MsgResources
|
||||
ModelAbout m -> Page.About.view m |> Element.map MsgAbout
|
||||
ModelContact m -> Page.Contact.view m |> Element.map MsgContact
|
||||
ModelNotFound m -> Page.NotFound.view m |> Element.map MsgNotFound
|
||||
ModelLanding m -> Page.Landing.view m |> Element.map MsgLanding
|
||||
ModelProducts m -> Page.Products.view m |> Element.map MsgProducts
|
||||
ModelResources m -> Page.Resources.view m |> Element.map MsgResources
|
||||
ModelAbout m -> Page.About.view m |> Element.map MsgAbout
|
||||
ModelContact m -> Page.Contact.view m |> Element.map MsgContact
|
||||
ModelNotFound m -> Page.NotFound.view m |> Element.map MsgNotFound
|
||||
in
|
||||
Element.el [Element.centerY ,Element.centerX] content
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
module Header exposing (Model, Msg, view, init, update)
|
||||
module Header exposing
|
||||
( Model
|
||||
, Msg
|
||||
, view
|
||||
, init
|
||||
, subscriptions
|
||||
, update
|
||||
)
|
||||
import Element exposing (Element)
|
||||
import Element.Events
|
||||
import Element.Border
|
||||
|
@ -9,6 +16,9 @@ type alias Msg = {}
|
|||
init : () -> Model
|
||||
init flags = {}
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ = Sub.none
|
||||
|
||||
update : Msg -> Model -> (Model, Cmd Msg)
|
||||
update msg model = (model, Cmd.none)
|
||||
|
||||
|
|
|
@ -60,8 +60,10 @@ update msg model =
|
|||
_ -> (model, Cmd.none)
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ =
|
||||
Sub.none
|
||||
subscriptions model = Sub.batch
|
||||
[ model.header |> Header.subscriptions |> Sub.map Header
|
||||
, model.page |> Body.subscriptions |> Sub.map Body
|
||||
]
|
||||
|
||||
|
||||
view : Model -> Browser.Document Msg
|
||||
|
|
|
@ -5,7 +5,6 @@ module Page.About exposing
|
|||
, init
|
||||
, update
|
||||
, subscriptions
|
||||
, cleanupSubcriptions
|
||||
)
|
||||
import Element exposing (Element)
|
||||
|
||||
|
@ -15,9 +14,6 @@ type alias Msg = {}
|
|||
init : () -> Model
|
||||
init flags = {}
|
||||
|
||||
cleanupSubcriptions : Model -> Cmd Msg
|
||||
cleanupSubcriptions _ = Cmd.none
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ = Sub.none
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ module Page.Contact exposing
|
|||
, init
|
||||
, update
|
||||
, subscriptions
|
||||
, cleanupSubcriptions
|
||||
)
|
||||
import Element exposing (Element)
|
||||
|
||||
|
@ -15,9 +14,6 @@ type alias Msg = {}
|
|||
init : () -> Model
|
||||
init flags = {}
|
||||
|
||||
cleanupSubcriptions : Model -> Cmd Msg
|
||||
cleanupSubcriptions _ = Cmd.none
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ = Sub.none
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ module Page.Landing exposing
|
|||
, init
|
||||
, update
|
||||
, subscriptions
|
||||
, cleanupSubcriptions
|
||||
)
|
||||
import Element exposing (Element)
|
||||
|
||||
|
@ -15,9 +14,6 @@ type alias Msg = {}
|
|||
init : () -> Model
|
||||
init flags = {}
|
||||
|
||||
cleanupSubcriptions : Model -> Cmd Msg
|
||||
cleanupSubcriptions _ = Cmd.none
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ = Sub.none
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ module Page.NotFound exposing
|
|||
, init
|
||||
, update
|
||||
, subscriptions
|
||||
, cleanupSubcriptions
|
||||
)
|
||||
import Element exposing (Element)
|
||||
|
||||
|
@ -15,9 +14,6 @@ type alias Msg = {}
|
|||
init : () -> Model
|
||||
init flags = {}
|
||||
|
||||
cleanupSubcriptions : Model -> Cmd Msg
|
||||
cleanupSubcriptions _ = Cmd.none
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ = Sub.none
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ module Page.Products exposing
|
|||
, init
|
||||
, update
|
||||
, subscriptions
|
||||
, cleanupSubcriptions
|
||||
)
|
||||
import Element exposing (Element)
|
||||
|
||||
|
@ -15,9 +14,6 @@ type alias Msg = {}
|
|||
init : () -> Model
|
||||
init flags = {}
|
||||
|
||||
cleanupSubcriptions : Model -> Cmd Msg
|
||||
cleanupSubcriptions _ = Cmd.none
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ = Sub.none
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ module Page.Resources exposing
|
|||
, init
|
||||
, update
|
||||
, subscriptions
|
||||
, cleanupSubcriptions
|
||||
)
|
||||
import Element exposing (Element)
|
||||
|
||||
|
@ -15,9 +14,6 @@ type alias Msg = {}
|
|||
init : () -> Model
|
||||
init flags = {}
|
||||
|
||||
cleanupSubcriptions : Model -> Cmd Msg
|
||||
cleanupSubcriptions _ = Cmd.none
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ = Sub.none
|
||||
|
||||
|
|
Loading…
Reference in a new issue