From 320f7fc62b1e20035fbd23d93fee0ce8d07dc3a4 Mon Sep 17 00:00:00 2001 From: Gnlow Date: Tue, 5 Dec 2023 10:46:37 +0900 Subject: [PATCH] refactor: Entry.events prop auto init --- src/Entry.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Entry.ts b/src/Entry.ts index 95535b6..c72a0be 100644 --- a/src/Entry.ts +++ b/src/Entry.ts @@ -38,10 +38,7 @@ export class Entry { constructor(project: Project) { this.project = project - this.events = { - start: [], - scene_start: [], - } + this.events = {} this.scenes = Object.fromEntries( this.project.scenes.map( @@ -138,6 +135,9 @@ export class Entry { ) } on(eventName: string, f: () => void) { + if (!this.events[eventName]) { + this.events[eventName] = [] + } this.events[eventName].push(f) } start() {