Chapter 5. Working with multiple windows

 

This chapter covers

  • Tracking multiple windows using the JavaScript Set data structure
  • Facilitating communication between the main process and multiple renderer processes
  • Using Node APIs to detect what platform the application is running on

Right now, when Fire Sale starts up, it creates a single window for the UI. When that window is closed, the application quits. Although this behavior is perfectly acceptable, we typically expect to be able to open multiple, independent windows. In this chapter, we convert Fire Sale from a single-window application to one that supports multiple windows. Along the way, we’ll explore new Electron APIs as well as some of JavaScript’s more recent additions. We also explore solutions to problems that occur when taking a main process that is configured to communicate with one renderer process (see figure 5.1) and refactoring it to manage a variable number of processes (see figure 5.2). The completed code at the end of this chapter can be found at http://mng.bz/V145. We start from the chapter-4 branch, however.

Figure 5.1. In chapter 4, we set up communication between the main process and one renderer process.
Figure 5.2. In this chapter, we update Fire Sale to support multiple windows and facilitate communication between them.

5.1. Creating and managing multiple windows

5.2. Improving the user experience of creating new windows

5.3. Integrating with macOS

Summary

sitemap