Last active
April 6, 2023 21:02
-
-
Save epequeno/2d12d021bd865582b0fcb1509373ba25 to your computer and use it in GitHub Desktop.
example of multiple elm apps on a single page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Elm 0.19.0 | |
module Blue exposing (main) | |
import Html exposing (..) | |
main = | |
div [] [ text "Hello from Blue!" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html class="no-js" lang="en-US"> | |
<head> | |
<title>Multiple Elm App Demo</title> | |
<script src="main.js"></script> | |
</head> | |
<body> | |
<div id="red"></div> | |
<p>Hello world! This is HTML5 Boilerplate.</p> | |
<div id="blue"></div> | |
<script> | |
var red = Elm.Red.init({ | |
node: document.getElementById('red') | |
}); | |
var blue = Elm.Blue.init({ | |
node: document.getElementById('blue') | |
}); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ elm make src/Red.elm src/Blue.elm --output main.js | |
$ tree | |
. | |
├── elm.json | |
├── index.html | |
├── main.js | |
└── src | |
├── Blue.elm | |
└── Red.elm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Elm 0.19.0 | |
module Red exposing (main) | |
import Html exposing (..) | |
main = | |
div [] [ text "Hello from Red!" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, Steven. Did you try this kind of "microservices front-end" approach on a big scale? I think it could be interesting next step to try Elm MicroApps talk to each other via Ports.