Get started with elm-runtime CDN
BSD3 licensed
Elm-runtime: library for Elm-Web interop, enabling browser execution and JS interaction.
Tags:- elm
- FRP
- functional
Stable version
Copied!
How to start using elm-runtime CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with elm-runtime CDN - cdnhub.io</title>
<script src="https://cdn.jsdelivr.net/npm/elm@0.19.1/dist/elm.min.js"></script>
<script src="https://cdn.cdnhub.io/elm-runtime/0.8.0.3/elm-runtime.min.js"></script>
<script src="main.js"></script>
</head>
<body>
<button id="button">Click me</button>
<script>
const init = Elm.init(() => {
const app = new App.Init();
document.getElementById('button').addEventListener('click', () => {
app.ports.main.send({ message: "Click" });
});
return {
app,
ports: {
main: app.ports.main,
},
};
});
init.ports.main.subscribe((message) => {
if (message.type === "response") {
alert(message.text);
}
});
</script>
</body>
</html>
Copied!