export default class State {

    constructor(data) {
        this.events = {}
        this.init(data)
    }

    init() {}
    update() {}
    draw() {}

    on(event, cb) {
        if (!this.events[event]) this.events[event] = []
        this.events[event].push(cb)
    }

    emit(event, data) {
        if (this.events[event]) {
            this.events[event].forEach(ev => ev(data))
        }
    }
}
