It is a bit trickier to build an event loop in reflex
than in reactive-banana
.
This is because the facilities provided by reflex
are lower-level and more fine-grained.
If you want something higher level you can use, there is refex-host
.
If you want to have a look at how to use the various low-level pieces and various things that you can do with them, this is the repository for you.
The canonical example is host.hs, and much of the work here is derived from that.
The simplest example rigs up an event loop for a pure event network which has an Event
as an input and a Behavior
as an output.
The next example rigs up an event loop for a pure event network which has an Event
as an input and a Event
as an output.
We now change the example so that we have multiple events for both the inputs and the outputs.
We add PostBuild
here, to give us easy access to an event which fires when our event loop starts.
We add PerformEvent
here, so that we can do IO
inside of our event network instead of bolting it on afterwards.
We split the previous example into an event network that is pure and an event network that is used to take care of the IO
.
We then create a function we can use to test the pure part of the event network.