Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an event that fires only once

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?

like image 749
Wheat Wizard Avatar asked Mar 07 '20 17:03

Wheat Wizard


People also ask

How do you make an event fire only once?

Using the once option We can pass an object as an argument to the addEventListener method and specify that the event is only handled once. This is achieved by passing the property once to the object. If we set once to true, the event will only be fired once.

Which method can be used to handle an event for just only one time?

Using once() Sometimes you want your application to respond to an event (or type of event) only one time (i.e., the first time the event occurs). To do this, Node provides the once() method. It is used just like the addListener() and on() methods, but allows for responding to the event only once.

How addEventListener works?

The method addEventListener() works by adding a function, or an object that implements EventListener , to the list of event listeners for the specified event type on the EventTarget on which it's called.

What is one in jQuery?

jQuery one() Method The one() method attaches one or more event handlers for the selected elements, and specifies a function to run when the event occurs. When using the one() method, the event handler function is only run ONCE for each element.


1 Answers

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.

like image 154
user2847643 Avatar answered Oct 22 '22 20:10

user2847643