Code RoomListener never unsubscribed
MediumPrep Room Coding #1644

Listener never unsubscribed

Code reviewCode quality & reviewMid–Senior~25 min

Review this Java event bus.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1public class EventBus {
2 private final List<Listener> listeners = new CopyOnWriteArrayList<>();
3 
4 public void subscribe(Listener l) { listeners.add(l); }
5 
6 public void publish(Event e) {
7 for (Listener l : listeners) l.onEvent(e);
8 }
9}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.