Reputation: 1010
The core Keyboard
signals, Keyboard.space
for example, are True
when the given key is pressed and False
otherwise. I want to give the signal from an on-screen button the same property.
I've got a button that sends a Bool
to a mailbox, but it always remains True
unless I send another message, but I can't find a clean way to do that after I use the value from the signal, and it would be nice to not have to worry if I decide to have multiple functions reading from the same mailbox later.
I think there might be a way to this with Signal.foldp
but if so, I can't find a good example of something similar. What would most conveinient is if there was a function with the signature Signal Bool -> Signal Bool
that would transform the signal into one that sent a False
after each True
is sent.
Upvotes: 0
Views: 48
Reputation: 2923
You can use something like:
Signal.dropRepeats <| Time.since Time.millisecond <| yourMailbox.signal
but it is advisable to use Elm Architecture and just think in terms of Actions rather than drop to such low level.
Upvotes: 0