CHAPTER 8The Bridge Pattern

In the world of API implementations, bridges are incredibly useful. In fact, they're probably one of the most underused patterns. Of all patterns, this is the simplest to start putting into practice immediately. If you're building a JavaScript API, this pattern can be used to ensure that the dependent classes and objects are coupled to it loosely. As defined by the Gang of Four, a bridge should "decouple an abstraction from its implementation so that the two can vary independently." Bridges are very beneficial when it comes to event-driven programming, which is a style that is used often in JavaScript.

If you're just entering the world of JavaScript API development, you're most likely going to be creating a lot of ...

Get Pro JavaScript™ Design Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.