0

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.

Ryan1729
  • 940
  • 7
  • 25

1 Answers1

0

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.

pdamoc
  • 2,798
  • 15
  • 19
  • Well what I'm doing is recreating an abstraction that already exists for the keyboard buttons. I've got this saved as a module so I don't need to do this "low level" stuff ever again. – Ryan1729 Mar 31 '16 at 09:49