Helper functions for recognising events. Mostly useful in
combination with Signal.sampleOn, although there are uses.
An EventSource is really just a Signal where we don't care about its
value, but only when it updates. A prime example is Mouse.clicks.
Simple way to make an event signal from any signal
Fires when the value of the input signal is equal to the given value.
NB: Repeated updates to the same value will make the EventSource
fire repeatedly.
See also: whenChangeTo.
Mouse.clicks == whenEqual True Mouse.isDownFires when the value of the input signal changes.
Fires when the value of the input signal changes to the given value.
spacebarPress = whenChangeTo True Keyboard.spacebarfoldp variationsfoldp on an EventSource.
toggleOnEnter = folde not False <| whenChangeTo True Keyboard.enter
At some point in the future Elm will probably support something like this:
That is,
EventSourcewill become an alias for anySignal awhere we hide theapart.Until then, there is the
esfunction to create an EventSource