The createEmitter function should create a new EventEmitter and register "open" and "close" event listeners. The callbacks for those events should be onOpen and onClose arguments, respectively. The opened and closed methods should raise the "open" and "close" events on the EventEmitter they will receive as emitter arguments. The callbacks should only be invoked once per emitter.
For example, after executing the following code, it should print "Opened!" and then "Closed!":
let emitter = createEmitter( () => console.log("Opened!"), () => console.log("Closed!") ); opened(emitter); closed(emitter);
- Example case: Wrong answer
- createEmitter registers the correct events: Exception
- open and close functions raise the correct events: Wrong answer
- Callbacks are only invoked once: Wrong answer