Engrain by ByteRush

JS.16.02 Mid-levelCore — asked often

EventEmitter / pub-sub

Comes up in: Coding, Low-level design

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • on, off, once, emit
  • unsubscribe function
  • removing during emit (copy listeners)
  • error event
  • wildcard (bonus)

Words you will know

observer patternpublish-subscribe

What you will practise

  • implement (worked → timed)

Interview questions this answers

  • Implement an EventEmitter with on, off, once and emit.