Book Image

JavaScript at Scale

By : Adam Boduch
Book Image

JavaScript at Scale

By: Adam Boduch

Overview of this book

Table of Contents (17 chapters)
JavaScript at Scale
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 4. Component Communication and Responsibilities

The preceding chapter focused on the what of components—what are they composed of and why. This chapter focuses on the glue in between our JavaScript components—the how. If our components are designed with a particular purpose in mind, then they need to communicate with other components to realize larger behavior. For example, a router component is unlikely to update the DOM or talk to the API. We have components that are good at those tasks, so other components can ask them to perform them, by communicating with them.

We'll start the chapter off with a look at communication models prevalent in frontend development. It's highly unlikely that we'll develop our own framework for inter-component communication since there are lots of robust libraries that already do this. What we're more interested in, from a JavaScript scaling perspective, is how the chosen communication model in our application prevents us from scaling, and what can be...