now routing subscriptions

This commit is contained in:
Yehowshua Immanuel 2025-01-01 20:17:48 -05:00
parent 18714713b6
commit 83d8196261
9 changed files with 32 additions and 34 deletions

View file

@ -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 import Element
@ -28,6 +28,16 @@ type Model
init : () -> Model init : () -> Model
init flags = ModelLanding (Page.Landing.init flags) 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 : String -> Model
handleRoute path = handleRoute path =
let let
@ -74,11 +84,11 @@ view : Model -> Element.Element Msg
view model = view model =
let let
content = case model of content = case model of
ModelLanding m -> Page.Landing.view m |> Element.map MsgLanding ModelLanding m -> Page.Landing.view m |> Element.map MsgLanding
ModelProducts m -> Page.Products.view m |> Element.map MsgProducts ModelProducts m -> Page.Products.view m |> Element.map MsgProducts
ModelResources m -> Page.Resources.view m |> Element.map MsgResources ModelResources m -> Page.Resources.view m |> Element.map MsgResources
ModelAbout m -> Page.About.view m |> Element.map MsgAbout ModelAbout m -> Page.About.view m |> Element.map MsgAbout
ModelContact m -> Page.Contact.view m |> Element.map MsgContact ModelContact m -> Page.Contact.view m |> Element.map MsgContact
ModelNotFound m -> Page.NotFound.view m |> Element.map MsgNotFound ModelNotFound m -> Page.NotFound.view m |> Element.map MsgNotFound
in in
Element.el [Element.centerY ,Element.centerX] content Element.el [Element.centerY ,Element.centerX] content

View file

@ -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 exposing (Element)
import Element.Events import Element.Events
import Element.Border import Element.Border
@ -9,6 +16,9 @@ type alias Msg = {}
init : () -> Model init : () -> Model
init flags = {} init flags = {}
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
update : Msg -> Model -> (Model, Cmd Msg) update : Msg -> Model -> (Model, Cmd Msg)
update msg model = (model, Cmd.none) update msg model = (model, Cmd.none)

View file

@ -60,8 +60,10 @@ update msg model =
_ -> (model, Cmd.none) _ -> (model, Cmd.none)
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg
subscriptions _ = subscriptions model = Sub.batch
Sub.none [ model.header |> Header.subscriptions |> Sub.map Header
, model.page |> Body.subscriptions |> Sub.map Body
]
view : Model -> Browser.Document Msg view : Model -> Browser.Document Msg

View file

@ -5,7 +5,6 @@ module Page.About exposing
, init , init
, update , update
, subscriptions , subscriptions
, cleanupSubcriptions
) )
import Element exposing (Element) import Element exposing (Element)
@ -15,9 +14,6 @@ type alias Msg = {}
init : () -> Model init : () -> Model
init flags = {} init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none subscriptions _ = Sub.none

View file

@ -5,7 +5,6 @@ module Page.Contact exposing
, init , init
, update , update
, subscriptions , subscriptions
, cleanupSubcriptions
) )
import Element exposing (Element) import Element exposing (Element)
@ -15,9 +14,6 @@ type alias Msg = {}
init : () -> Model init : () -> Model
init flags = {} init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none subscriptions _ = Sub.none

View file

@ -5,7 +5,6 @@ module Page.Landing exposing
, init , init
, update , update
, subscriptions , subscriptions
, cleanupSubcriptions
) )
import Element exposing (Element) import Element exposing (Element)
@ -15,9 +14,6 @@ type alias Msg = {}
init : () -> Model init : () -> Model
init flags = {} init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none subscriptions _ = Sub.none

View file

@ -5,7 +5,6 @@ module Page.NotFound exposing
, init , init
, update , update
, subscriptions , subscriptions
, cleanupSubcriptions
) )
import Element exposing (Element) import Element exposing (Element)
@ -15,9 +14,6 @@ type alias Msg = {}
init : () -> Model init : () -> Model
init flags = {} init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none subscriptions _ = Sub.none

View file

@ -5,7 +5,6 @@ module Page.Products exposing
, init , init
, update , update
, subscriptions , subscriptions
, cleanupSubcriptions
) )
import Element exposing (Element) import Element exposing (Element)
@ -15,9 +14,6 @@ type alias Msg = {}
init : () -> Model init : () -> Model
init flags = {} init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none subscriptions _ = Sub.none

View file

@ -5,7 +5,6 @@ module Page.Resources exposing
, init , init
, update , update
, subscriptions , subscriptions
, cleanupSubcriptions
) )
import Element exposing (Element) import Element exposing (Element)
@ -15,9 +14,6 @@ type alias Msg = {}
init : () -> Model init : () -> Model
init flags = {} init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none subscriptions _ = Sub.none