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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.