Created
July 28, 2015 11:12
-
-
Save kouphax/6c5598f42e11ab1a873a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module Confirm where | |
import Html exposing (..) | |
import Html.Events exposing (..) | |
import Signal exposing (..) | |
type Action = NoOp | Prompt | |
actions : Signal.Mailbox Action | |
actions = | |
Signal.mailbox NoOp | |
-- PORTS -------------------------------- | |
port getName : Signal String | |
port confirm : Signal Int | |
port confirm = | |
actions.signal | |
|> filter (\s -> s == Prompt) NoOp | |
|> map (always 0) -- I don't really care about the value (impurity) | |
-- VIEWS -------------------------------- | |
view signal = | |
div [] | |
[ text signal, | |
button [ onClick actions.address Prompt ] | |
[ text "Set Name"]] | |
main : Signal Html | |
main = Signal.map view getName |
This file contains hidden or 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> | |
<head> | |
<meta charset="UTF-8"> | |
<script type="text/javascript" src="confirm.js"></script> | |
</head> | |
<body> | |
</body> | |
<script type="text/javascript"> | |
var app = Elm.fullscreen(Elm.Confirm, { getName: "" }); | |
app.ports.confirm.subscribe(function(){ | |
var value = window.prompt("Name?"); | |
app.ports.getName.send(value); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment