Apanatshka/elm-signal-extra/5.2.1

NOTE: this package is not compatible with Elm 0.19.1

Signal.Discrete

Helper functions for recognising events. Mostly useful in combination with Signal.sampleOn, although there are uses.

EventSource

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.

type alias EventSource =
Signal ()

At some point in the future Elm will probably support something like this:

type alias EventSource = Signal _

That is, EventSource will become an alias for any Signal a where we hide the a part.
Until then, there is the es function to create an EventSource

es : Signal a -> EventSource

Simple way to make an event signal from any signal

Basics

whenEqual : a -> Signal a -> EventSource

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.isDown
whenChange : Signal a -> EventSource

Fires when the value of the input signal changes.

whenChangeTo : a -> Signal a -> EventSource

Fires when the value of the input signal changes to the given value.

spacebarPress = whenChangeTo True Keyboard.spacebar

foldp variations

folde : (b -> b) -> b -> EventSource -> Signal b

foldp on an EventSource.

toggleOnEnter = folde not False <| whenChangeTo True Keyboard.enter