I personally have no interest or use for templates in Cycle.JS or Elm, but 
OP does, but I'm not sure if Jade templates are used much in Cycle.JS 
either. His point is correct that in Cycle.JS View function, there's never 
any specification of what exact events the Intent function will process, 
only a CSS selector the Intent function uses to filter out the parts of the 
view it's interested in processing,
https://cycle.js.org/basic-examples.html
so the View in Cycle.js has no equivalent to
http://package.elm-lang.org/packages/elm-lang/html/2.0.0/Html-Events
only
https://github.com/ohanhi/hyperscript-helpers
so to summarize your elm view must specify what events, e.g. onClick, it 
will generate,while the Cycle.JS View function never does, e.g
function view(state$) {
return state$.map(({color, width}) => {
const style = {
border: '1px solid #000',
background: 'none repeat scroll 0% 0% ' + color,
width: width + 'px',
height: '70px',
display: 'block',
padding: '20px',
margin: '10px 0px'
};
return div('.item', {style}, [
input('.color-field', {
attrs: {type: 'text', value: color}
}),
div('.slider-container', [
input('.width-slider', {
attrs: {type: 'range', min: '200', max: '1000', value: width}
})
]),
div('.width-content', String(width)),
button('.remove-btn', 'Remove')
]);

from 
https://github.com/cyclejs/cyclejs/blob/master/examples/many/src/Item.js
Note, no events specified anywhere. This makes Tylor Steinberger's 
extremely simple Cycle.JS w/Jade Proof of Concept example possible, as 
noted by OP, but TS doesn't seem to be very enthusiastic about the idea, 
for performance and other reasons.

Yes I understand Elm is no longer First Order FRP
http://elm-lang.org/blog/farewell-to-frp
where Cycle.JS is higher order FRP
https://twitter.com/andrestaltz/status/730065452991455232
which Evan help clarify the differences in
https://www.youtube.com/watch?v=Agu6jipKfYw



On Friday, January 20, 2017 at 10:00:33 PM UTC-8, Peter Damoc wrote:
>
>
> On Sat, Jan 21, 2017 at 2:15 AM, jphedley <jphe...@gmail.com <javascript:>
> > 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.

Reply via email to