5

I find myself in desire of a function with the signature:

-- VtyWidget is from https://github.com/reflex-frp/reflex-vty
now :: a -> VtyWidget t m (Event t a)

For some m. This function would take an element and produce a widget which fires an event once, immediately.

I cannot find such a function or any things that I could use to build this.

I can build things of this type like:

const (pure never)

But that ignores the input and never fires an event.

Is there a way to do this? Or am I not supposed to do this sort of thing?

Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
Wheat Wizard
  • 3,982
  • 14
  • 34
  • When is "immediately", in relation to other events (say, button clicks) that can happen in the Vty application? – danidiaz Mar 07 '20 at 19:29
  • @danidiaz Immediately is just as soon as possible. I would like it to fire the event pretty much as soon as it renders the widget or even a moment before. – Wheat Wizard Mar 07 '20 at 19:31
  • I'm not very knowledgeable about reflex, but `VtyWidget` seems to have a `TriggerEvent` instance http://hackage.haskell.org/package/reflex-0.6.2.4/docs/Reflex-TriggerEvent-Class.html that would let you define a "custom" event which you could trigger manually from `IO` a single time, once the app is running. Not sure this is the best approach though. – danidiaz Mar 07 '20 at 21:04

1 Answers1

2

I'm not sure I fully understand the question but it vaguely sounds like you may want getPostBuild. That is what I use whenever I want things to happen once during initialization of a widget.

user2847643
  • 2,893
  • 14
  • 22