Patterns: emitters, observers, stores: interview questions

Event emitters, the observer pattern, publish and subscribe, and small state stores with change listeners. 7 questions from the Front End Interview Handbook. 5 have our own answer, built up from basic to advanced, with code that is proved by tests (how answers are checked).

  1. Observer patternPatterns: emitters, observers, stores · basicJavaScript codingcheckednot tried
  2. Implement a Backbone-style StoreData class with key/value pairs and change listeners. One variation included a global change listener and required unset to remove data while retaining subscriptions. Setting the attribute again should notify those listeners. SourcePatterns: emitters, observers, stores · reported at AirbnbJavaScript codingcheckednot tried
  3. Implement an Event Emitter (Emitter Pattern).Patterns: emitters, observers, stores · reported at MetaJavaScript codingcheckednot tried
  4. Implement Event Emitter.Patterns: emitters, observers, stores · reported at RipplingJavaScript codingcheckednot tried
  5. Implement an event emitter progressively in 3 stages of increasing complexity. Senior / staff candidates are expected to clear all 3 stages.Patterns: emitters, observers, stores · reported at RobinhoodJavaScript codingcheckednot tried
  6. Build a job board: fetch and display posts, add a "load more" button, then layer on infinite scroll using IntersectionObserver, throttling on scroll, and deduping of fetched items.Async, promises and timers, Arrays and objects · reported at RipplingUser interface codingno answer yetnot tried
  7. Implement a key-value store with commit and rollback operations.Patterns: emitters, observers, stores · reported at RipplingAlgorithmsno answer yetnot tried