On Sat, Jan 21, 2017 at 2:15 AM, jphedley <jphed...@gmail.com> wrote:
> I wasn't aware of Jade Templates being a common use case for the Cycle.js > community. I was only aware of this issue- > https://github.com/cyclejs/cyclejs/issues/321 > resulting in this proof of concept- > http://www.webpackbin.com/Nkd5aKiIf > which is made possible by Cycle.JS not attaching event handlers in the > view function, as noted by Andre Statlz in this discussion, > https://www.reddit.com/r/javascript/comments/3zr6i0/ > conversation_whats_the_core_differences_between/ > unlike Elm. > Well, Elm doesn't have templates because elm doesn't need templates. It has the entire language available for you to build whatever html you want based on your model. Also, Elm doesn't attach event handlers in the view function, it just describes what kind of message would the event generate. You can think of these as translators from the language of the html element to the language of your app. So, instead of generating a "click" event, a button will generate a specific message. If you want your template to have no idea of these messages you can give it the messages as parameters. You will then use this template in some Elm Architecture construct Your entire example, in Elm would look like this: module Main exposing (..) import Html exposing (beginnerProgram, div, button, h1, text) import Html.Events exposing (onClick) main = beginnerProgram { model = 0, view = view, update = update } incTemplate msg count = div [] [ button [ onClick msg ] [ text "Click me" ] , h1 [] [ text (toString count) ] ] view model = incTemplate Increment model type Msg = Increment update msg model = case msg of Increment -> model + 1 I think it looks clearer. As a side note, the Elm that is mentioned in that reddit discussion you linked is no more. Signals and FRP constructs are gone from the language. All we have now is The Elm Architecture. -- There is NO FATE, we are the creators. blog: http://damoc.ro/ -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.