still compiles but probably don't need cleanupSubcriptions function

This commit is contained in:
Yehowshua Immanuel 2025-01-01 18:51:17 -05:00
parent b9db2eaa63
commit 18714713b6
10 changed files with 113 additions and 9 deletions

View file

@ -18,6 +18,7 @@ Now open `http://127.0.0.1:8080` in your browser.
# TODO
- [x] Add Makefile
- [ ] Run `uglify` twice as per [this link](https://github.com/rtfeldman/elm-spa-example/tree/master?tab=readme-ov-file#production-build)
- [ ] Clicking in upper left should go to landing page.
- [ ] Add GPLV3 License
- [ ] Add `make release` target that is nix ready...

View file

@ -9,12 +9,12 @@
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"elm/json": "1.1.3",
"elm/url": "1.0.0",
"kageurufu/elm-websockets": "1.0.1",
"mdgriffith/elm-ui": "1.1.8"
},
"indirect": {
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.3"
}

View file

@ -39,7 +39,7 @@ init flags url key =
, header = header
}
in
(model, Cmd.none)
(model, Ports.socketOpen)
update : Msg -> Model -> (Model, Cmd Msg)

View file

@ -1,4 +1,12 @@
module Page.About exposing (Model, Msg, view, init, update)
module Page.About exposing
( Model
, Msg
, view
, init
, update
, subscriptions
, cleanupSubcriptions
)
import Element exposing (Element)
type alias Model = {}
@ -7,6 +15,12 @@ type alias Msg = {}
init : () -> Model
init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
update : Msg -> Model -> (Model, Cmd Msg)
update msg model = (model, Cmd.none)

View file

@ -1,4 +1,12 @@
module Page.Contact exposing (Model, Msg, view, init, update)
module Page.Contact exposing
( Model
, Msg
, view
, init
, update
, subscriptions
, cleanupSubcriptions
)
import Element exposing (Element)
type alias Model = {}
@ -7,6 +15,13 @@ type alias Msg = {}
init : () -> Model
init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
update : Msg -> Model -> (Model, Cmd Msg)
update msg model = (model, Cmd.none)

View file

@ -1,4 +1,12 @@
module Page.Landing exposing (Model, Msg, view, init, update)
module Page.Landing exposing
( Model
, Msg
, view
, init
, update
, subscriptions
, cleanupSubcriptions
)
import Element exposing (Element)
type alias Model = {}
@ -7,6 +15,12 @@ type alias Msg = {}
init : () -> Model
init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
update : Msg -> Model -> (Model, Cmd Msg)
update msg model = (model, Cmd.none)

View file

@ -1,4 +1,12 @@
module Page.NotFound exposing (Model, Msg, view, init, update)
module Page.NotFound exposing
( Model
, Msg
, view
, init
, update
, subscriptions
, cleanupSubcriptions
)
import Element exposing (Element)
type alias Model = {}
@ -7,6 +15,12 @@ type alias Msg = {}
init : () -> Model
init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
update : Msg -> Model -> (Model, Cmd Msg)
update msg model = (model, Cmd.none)

View file

@ -1,4 +1,12 @@
module Page.Products exposing (Model, Msg, view, init, update)
module Page.Products exposing
( Model
, Msg
, view
, init
, update
, subscriptions
, cleanupSubcriptions
)
import Element exposing (Element)
type alias Model = {}
@ -7,6 +15,12 @@ type alias Msg = {}
init : () -> Model
init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
update : Msg -> Model -> (Model, Cmd Msg)
update msg model = (model, Cmd.none)

View file

@ -1,4 +1,12 @@
module Page.Resources exposing (Model, Msg, view, init, update)
module Page.Resources exposing
( Model
, Msg
, view
, init
, update
, subscriptions
, cleanupSubcriptions
)
import Element exposing (Element)
type alias Model = {}
@ -7,6 +15,12 @@ type alias Msg = {}
init : () -> Model
init flags = {}
cleanupSubcriptions : Model -> Cmd Msg
cleanupSubcriptions _ = Cmd.none
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
update : Msg -> Model -> (Model, Cmd Msg)
update msg model = (model, Cmd.none)

View file

@ -1,10 +1,28 @@
port module Ports exposing (socket)
port module Ports exposing
( socketOnEvent
, socketSend
, socketOpen
)
import Websockets
import Json.Encode as Encode
port webSocketCommand : Websockets.CommandPort msg
port webSocketEvent : Websockets.EventPort msg
socketName : String
socketName = "app"
socketOnEvent : Websockets.EventHandlers msg -> Sub msg
socketOnEvent eventHandlers =
socket.onEvent eventHandlers
socketSend : Encode.Value -> Cmd msg
socketSend data = socket.send socketName data
socketOpen : Cmd msg
socketOpen = socket.open socketName "/ws/" []
socket : Websockets.Methods msg
socket =
Websockets.withPorts