The Elm architecture is that there is a single state which is only updated 
by messages, so observables (or signals) do not really fit into that. If 
you want to count the number of clicks, then you count the number of clicks 
and keep track of it in your model. If you want to handle a swipe then you 
subscribe to mouse events and keep track of them, etc.

The fact that you can combine observables and get very "complex" effects is 
true, but the point of Elm is not to make programs complex, but to make 
them simple. The reason there is a single state and only messages are 
allowed to update it is not because it's hard to make the language more 
complex with multiple states etc, but because it makes the program simple. 
You know what can cause the state to change, a message. All messages pass 
through the update function. You have control over the complexity of your 
program.

But that doesn't mean that you cannot do sophisticated things, of course. 
It's not hard to keep track of the number of clicks in your model and 
compare the time. If this is a feature that many people will want then it 
could be made into a library with a good API.

If you want to handle swipe events, perhaps you can use my html5 drag and 
drop module as an 
inspiration. 
http://package.elm-lang.org/packages/norpan/elm-html5-drag-drop/latest

Swipe and drag are similar so the solutions should look similar.

The versatility of observables is tempting but my experience is that when 
the application gets bigger you get lost in them. They require discipline. 
The point with the Elm architecture is that discipline is built-in.

Den torsdag 9 mars 2017 kl. 13:39:30 UTC+1 skrev Răzvan Cosmin Rădulescu:
>
> Hi Martin, thanks for not bashing me from the start because I brought up 
> reactive... Quite interesting it's happened a few times already.
>
> So, anything involving gestures for example. There is no Elm module for 
> feature detection (swipe, tap, double tap etc.) so I wanted to learn by 
> doing but unfortunately I discovered that the reactive part was dropped 
> with v0.17.1. To be more specific let's take double tap (not click as this 
> is already a DOM event). Here's a link on how this would be done in RxJS: 
> http://jsfiddle.net/staltz/4gGgs/27/.
>
> As far as I can tell in Elm there's no other way but to keep track of 
> state and do all sorts of "low level" calculations.
>
> Thanks again Martin
>
>

-- 
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