Created
October 20, 2015 11:34
-
-
Save kadikraman/cf8b199dc181001c18f9 to your computer and use it in GitHub Desktop.
Mailboxes in Elm
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
| import Html exposing (..) | |
| import Html.Events exposing (..) | |
| import Html.Attributes exposing (..) | |
| view : Signal.Address String -> String -> Html | |
| view address message = | |
| div [] | |
| [ input | |
| [ type' "string", | |
| placeholder "input", | |
| name "points", | |
| on "input" targetValue (\v -> Signal.message address v) | |
| ] | |
| [ ], | |
| p [ ] [ text ("Input: " ++ message)] | |
| ] | |
| inbox : Signal.Mailbox String | |
| inbox = | |
| Signal.mailbox "" | |
| main : Signal Html | |
| main = | |
| Signal.map (view inbox.address) inbox.signal | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment