Coding task · JavaScript and TypeScript course · Module 9: Design Patterns and Architecture
Practice: EventEmitter with Time Simulation
Create a Jurassic Park time system based on EventEmitter that emits the hour:changed, day:changed and event:triggered events.
Task
The index.js file has the EventEmitter from the event-driven architecture lesson and a ParkTimeSystem class that simulates the hours in the park. Fill in the blanks: ___BLANK1___ is the array method that removes one listener at the found index in off(), ___BLANK2___ is the class that ParkTimeSystem extends to get the on, off and emit methods, and ___BLANK3___ is the array method that picks from the scheduled events only those for the current hour. Every hour advanceHour() emits 'hour:changed' with the hour and the day, after midnight first 'day:changed' with the day number, and every event scheduled with schedule(hour, name) for that hour emits 'event:triggered' with the name and the hour. start(intervalMs) starts a setInterval loop, and stop() stops it.