Skip to content

Instantly share code, notes, and snippets.

@Chadtech
Last active March 23, 2016 21:06
Show Gist options
  • Select an option

  • Save Chadtech/2dab0e65986a516e3a30 to your computer and use it in GitHub Desktop.

Select an option

Save Chadtech/2dab0e65986a516e3a30 to your computer and use it in GitHub Desktop.
main = document.getElementById 'main'
app = Elm.embed Elm.Main, main
backEnd = (msg) ->
# ...
{submitEmail, updateEmail} = app.ports
email = "ye"
submitEmail.subscribe (what) ->
console.log 'Submit Email!', what, email
backEnd email: email
updateEmail.subscribe (what) ->
console.log 'Update Email!', what
email = what
-- ..
email : String -> Address Action -> Html
email content address =
div
[ style
[ ("margin", "auto")
, ("width", "60%")
]
]
[ input
[ class "field"
, placeholder "enter your email here"
, value content
, on "input" targetValue
<| message inputString.address
--<| (\string -> Signal.message address (EmailField string))
]
[]
, button
[ style
[ ("background-color", "#030907")
, ("border", "none" )
, ("outline", "none" )
]
, class "point link"
, on "click" targetValue
<| message subscribePress.address
]
[ text "subscribe" ]
]
port submitEmail : Signal String
port submitEmail =
Signal.map (\str -> str) subscribePress.signal
port updateEmail : Signal String
port updateEmail =
Signal.map (\str -> str) inputString.signal
inputString : Mailbox String
inputString = mailbox "these strings dont matter"
subscribePress : Mailbox String
subscribePress = mailbox "hell ye mf"
- ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment