LLD - Behavioral Design Patterns — Part 2
In the following Mediator implementation, what is the main issue?
class Mediator {
notify(sender, event) {
if (event === 'start') {
sender.start();
} else if (event === 'stop') {
sender.stop();
}
}
}
class Component {
start() { console.log('Started'); }
stop() { console.log('Stopped'); }
}
const mediator = new Mediator();
const comp = new Component();
mediator.notify(comp, 'start');