summary refs log blame commit diff stats
path: root/tests/js/tderef.nim
blob: ddb91bd42ac7ed6734807f5b6ee52a6488187a69 (plain) (tree)



















                                                                       
discard """
  output: '''true
'''
"""

import tables

type EventStore = Table[string, seq[proc ()]]

proc newEventStore(): EventStore =
  initTable[string, seq[proc ()]]()

proc register(store: var EventStore, name: string, callback: proc ()) =
  if not store.hasKey(name):
    store[name] = @[]
  store[name].add(callback)

var store = newEventStore()
store.register("test", proc () = echo "true")
store["test"][0]()