Module event

This module implements support for event listeners. The Event type represents an event that can triggered and subscribed to.

Types

CallbackId* = int64
  Source Edit
Event*[T] = ref object
  callbacks: Table[CallbackId, proc (arg: T)]
  nextId: CallbackId
  executor: LoopExecutor
  Source Edit

Procs

proc newEvent*[T](t: var Event[T])
  Source Edit
proc newEvent*[T](): Event[T]
  Source Edit
proc addListener*[T](ev: Event[T]; callback: proc (arg: T)): CallbackId {.
discardable
.}
  Source Edit
proc addListener*(ev: Event[void]; callback: proc ()): CallbackId {.
discardable
.}
  Source Edit
proc removeListener*[T](ev: Event[T]; evId: CallbackId)
  Source Edit
proc removeAllListeners*[T](ev: Event[T])
  Source Edit
proc callListenerNow*[T](ev: Event[T]; arg: T)
Call listeners for event ev immediately.   Source Edit
proc callListener*[T](ev: Event[T]; arg: T)
Call listeners for event ev in a next tick of the event loop.   Source Edit
proc callListener*(ev: Event[void])
Call listeners for event ev in a next tick of the event loop.   Source Edit