/Trigger-Nim

A basic event system implementation for Nim using no macro magic or syntax sugar!

Primary LanguageNim

Trigger-Nim

Note: This is not going to be maintained purely because I think it's limited in how it can be used, and I much prefer Pulse when compared to this. Use that, or fork this repo instead please!

Trigger is a simple and half-assed attempt at an event system written in Nim, made for use in Nimberite! An example of how to use it:

type
  # Unneeded but good for clarity
  ListenerProc = proc(val: int)
  EventData = (int,)

let eventSystem = eventSystem[ListenerProc, EventData]()

discard eventSystem.addListener(
  proc(val: int) =
    echo "A: ", val
)

discard eventSystem.addListener(
  proc(val: int) =
    echo "B: ", val
)

eventSystem.fire (1,)
eventSystem.fire (2,)