package me.eater.threedom.event

import me.eater.threedom.dom.INode
import me.eater.threedom.generated.EventNames

interface EventDispatcher {
    fun trigger(eventName: String, event: Event<*>) = trigger(eventName, event.source, event)
    fun trigger(eventName: String, targetNode: INode<*>, event: Event<*>)
}

inline fun <reified T> EventDispatcher.trigger(event: Event<T>) =
    trigger(EventNames.getEventName<T>(), event)

inline fun <reified T> EventDispatcher.trigger(target: INode<*>, event: Event<T>) =
    trigger(EventNames.getEventName<T>(), target, event)
