Reactive Patterns with RxJS for Angular
eBook - ePub

Reactive Patterns with RxJS for Angular

Lamis Chebbi

Buch teilen
  1. 224 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Reactive Patterns with RxJS for Angular

Lamis Chebbi

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Discover how you can leverage the reactive paradigm with RxJS in your Angular applications using some common patterns and techniques that can be implemented in real-world use cases

Key Features

  • Learn how to write clean, maintainable, performant, and optimized Angular web applications using reactive patterns
  • Explore various RxJS operators and techniques in detail to improve the testing and performance of your code
  • Switch from an imperative mindset to reactive by comparing both

Book Description

RxJS is a fast, reliable, and compact library for handling asynchronous and event-based programs. It is a first-class citizen in Angular and enables web developers to enhance application performance, code quality, and user experience, so using reactive patterns in your Angular web development projects can improve user interaction on your apps, which will significantly improve the ROI of your applications.This book is a step-by-step guide to learning everything about RxJS and reactivity. You'll begin by understanding the importance of the reactive paradigm and the new features of RxJS 7. Next, you'll discover various reactive patterns, based on real-world use cases, for managing your application's data efficiently and implementing common features using the fewest lines of code.As you build a complete application progressively throughout the book, you'll learn how to handle your app data reactively and explore different patterns that enhance the user experience and code quality, while also improving the maintainability of Angular apps and the developer's productivity. Finally, you'll test your asynchronous streams and enhance the performance and quality of your applications by following best practices.By the end of this RxJS Angular book, you'll be able to develop Angular applications by implementing reactive patterns.

What you will learn

  • Understand how to use the marble diagram and read it for designing reactive applications
  • Work with the latest features of RxJS 7
  • Build a complete Angular app reactively, from requirement gathering to deploying it
  • Become well-versed with the concepts of streams, including transforming, combining, and composing them
  • Explore the different testing strategies for RxJS apps, their advantages, and drawbacks
  • Understand memory leak problems in web apps and techniques to avoid them
  • Discover multicasting in RxJS and how it can resolve complex problems

Who this book is for

If you're an Angular developer who wants to leverage RxJS for building reactive web applications, this is the book for you. Beginner-level experience with Angular and TypeScript and knowledge of functional programming concepts is assumed.

]]>

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Reactive Patterns with RxJS for Angular als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Reactive Patterns with RxJS for Angular von Lamis Chebbi im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Informatica & Programmazione in JavaScript. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Part 1 – Introduction

In this section, you will understand the importance of using the reactive paradigm in an Angular application, as well as the new features of RxJS 7. In the third chapter, we will introduce the application that we are going to progressively build as we go through the book.
This part comprises the following chapters:
  • Chapter 1, The Power of the Reactive Paradigm
  • Chapter 2, RxJS 7 – The Major Features
  • Chapter 3, A Walkthrough of the Application

Chapter 1: The Power of the Reactive Paradigm

This book is based entirely on useful reactive patterns in Angular applications. Reactive patterns are reusable solutions to a commonly occurring problem using reactive programming. Behind all of these patterns, there is a new way of thinking, new architecture, new coding styles, and new tools.
I know you are impatient to write your first reactive pattern in Angular, but before doing that, and to help you take full advantage of all the RxJS patterns and leverage the reactive paradigm, we will start by explaining, in detail, all the fundamentals. Additionally, we will prepare the groundwork for the following chapters. First, let's start with a basic understanding of the reactive paradigm, its advantages, and the problems it solves. And best of all, let's get into the reactive mindset and start thinking reactively.
We will begin by highlighting the pillars and the advantages of the reactive paradigm. Then, we will describe the relationship between Angular and RxJS. Finally, we will explain the Marble diagram and why it is useful.
Giving an insight into the fundamentals of the reactive paradigm is incredibly important. This will ensure you get the basics right, help you understand the usefulness of the reactive approach, and consequently, help you determine which situation it is best to use it in.
In this chapter, we're going to cover the following topics:
  • Exploring the pillars of reactive programming
  • Using RxJS in Angular and its advantages
  • Learning about the marble diagram – our secret weapon

Technical requirements

This chapter does not require an environment setup or installation steps. All the code snippets here are just examples to illustrate the concepts. This book assumes that you have a basic understanding of Angular and RxJS.

Exploring the pillars of reactive programming

Let's begin with a little bit of background!
Reactive programming is among the major programming paradigms used by developers worldwide. Every programming paradigm solves some problems and has its own advantages. By definition, reactive programming is programming with asynchronous data streams and is based on observer patterns. So, let's talk about these pillars of reactive programming!

Data streams

Data streams are the spine of reactive programming. Everything that might change or happen over time (you don't know when exactly) is represented as a stream, such as data, events, notifications, and messages. Reactive programming is about reacting to changes as soon as they are emitted!
An excellent example of data streams is UI events. Let's suppose that we have an HTML button, and we want to execute an action whenever a user clicks on it. Here, we can think of the click event as a stream:
//HTML code
<button id='save'>Save</button>
//TS code
const saveElement = document.getElementById('save');
saveElement.addEventListener('click', processClick);
function processClick(event) {
console.log('Hi');
}
As implemented in the preceding code snippet, in order to react to this click event, we register an EventListener event. Then, every time a click occurs, the processClick method is called to execute a side effect. In our case, we are just logging Hi in the console.
As you might have gathered, to be able to react when something happens and execute a side effect, you should listen to the streams to become notified. We can say listen or observe to get closer to the reactive terminology. And this leads us to the observer design pattern, which is at the heart of reactive programming.

Observer patterns

The observer pattern is based on two main roles: a publisher and a subscriber.
A publisher maintains a list of subscribers and notifies them or propagates a change every time there is an update. On the other hand, a subscriber performs an update or executes a side effect every time they receive a notification from the publisher:
Figure 1.1 – The observer pattern
Figure 1.1 – The observer pattern
So, to get notified about any updates, you need to subs...

Inhaltsverzeichnis