Movatterモバイル変換


[0]ホーム

URL:


Packt
Search iconClose icon
Search icon CANCEL
Subscription
0
Cart icon
Your Cart(0 item)
Close icon
You have no products in your basket yet
Save more on your purchases!discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Profile icon
Account
Close icon

Change country

Modal Close icon
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timerSALE ENDS IN
0Days
:
00Hours
:
00Minutes
:
00Seconds
Home> Web Development> Front End Web Development> Reactive Patterns with RxJS for Angular
Reactive Patterns with RxJS for Angular
Reactive Patterns with RxJS for Angular

Reactive Patterns with RxJS for Angular: A practical guide to managing your Angular application's data reactively and efficiently using RxJS 7

Arrow left icon
Profile Icon Lamis Chebbi
Arrow right icon
€8.98€32.99
Full star iconFull star iconFull star iconFull star iconHalf star icon4.1(15 Ratings)
eBookApr 2022224 pages1st Edition
eBook
€8.98 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.98 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
Product feature iconAI Assistant (beta) to help accelerate your learning

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Table of content iconView table of contentsPreview book icon Preview Book

Reactive Patterns with RxJS for Angular

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 theMarble 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 codeconst 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 anEventListener event. Then, every time a click occurs, theprocessClick method is called to execute a side effect. In our case, we are just loggingHi 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 saylisten or observe to get closer to the reactive terminology. And this leads us to theobserver 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 subscribe to the publisher. A real-world analogy would be anewsletter; you don't get any emails if you don't subscribe to a newsletter.

This leads us to the building blocks of RxJS. They include the following:

  • Observables: These are a representation of the data streams that notify the observers of any change.
  • Observers: These are theconsumers of the data streams emitted by observables.

RxJS combines the observer pattern with the iterator pattern and functional programming to process and handle asynchronous events.

This was a reminder of the fundamentals of reactive programming. Remember, it is crucial to understand when to put a reactive implementation in place and when to avoid it.

In general, whenever you have to handle asynchronous tasks in your Angular application, always think of RxJS. The main advantages of RxJS over other asynchronous APIs are listed as follows:

  • RxJS makes dealing with event-based programs, asynchronous data calls, and callbacks an easy task.
  • Observables guarantee consistency. They emit multiple values over time so that you can consume continuous data streams.
  • Observables are lazy; they are not executed until you subscribe to them. This helps with writing declarative code that is clean, efficient, and easy to understand and maintain.
  • Observables can be canceled, completed, and retrieved at any moment. This makes a lot of sense in many real-world scenarios.
  • RxJS provides many operators with a functional style to manipulate collections and optimize side effects.
  • Observables push errors to the subscribers and provide a clean way to handle errors.
  • RxJS allows you to write clean and efficient code to handle asynchronous data in your application.

Now that we have given some insight into the reactive programming pillars and detailed the major advantages of RxJS, let's shed some light on the relationship between Angular and RxJS.

Using RxJS in Angular and its advantages

RxJS is a first-class citizen inAngular. It is part of theAngular ecosystem and is used in many features to handle asynchronous operations. Primarily, this includes the following:

  • HTTP client module
  • Router module
  • Reactive forms
  • Event emitter
  • Async pipe

We will discuss each of the following concepts in the subsequent subsections.

Note

We recommend taking a quick look athttps://angular.io/docs. Here, you can find further details about the features mentioned earlier.

The HTTP client module

You might befamiliar with the HTTP client API provided by Angular in order to communicate with your server over the HTTP protocol. TheHttpClient service is based on observables to manage all transactions. This means that the result of calling the API methods (such asGET,PATCH,POST, orPUT) is an observable.

In the following code snippet, we have an example of an Angular service that injects theHttpClient service and fetches data from the server using theHttpClient.get() method:

Import { Injectable } from '@angular/core';import { HttpClient } from '@angular/common/http';import { Observable} from 'rxjs';import { environment } from '@env/environment';const BASE_PATH = environment.basePath;@Injectable()export class RecipesService {constructor(private http: HttpClient) { }getRecipes(): Observable<Recipe[]> {return this.http.get<Recipe[]>(`${BASE_PATH}/recipes/search/all`);}

The following is the content of theenvironment.ts file where we define thebasePath property of our backend:

export const environment = {  basePath: '/app/rest',  production: false};

ThegetRecipes() method or, to be more accurate, the call tothis.http.get<Recipe>(`${BASE_PATH}/recipes/search`) returns an observable that you should subscribe to in order to issue theGET request to the server. Please note that this is an example of an HTTP transaction, and it is the same for all of the other HTTP methods available in the API (such asPOST,PUT, andPATCH)

For those familiar with promise-based HTTP APIs, you might be wondering, in this case, what the advantages of using observables are.

Well, there are a lotof advantages but the most important ones are listed as follows:

  • Observables are cancellable, so you can cancel the HTTP request whenever you want by calling the unsubscribe method.
  • Also, you can retry HTTP requests when an error occurs or an exception is thrown.
  • The server's response cannot be mutated by observables, although this can be the case when chainingthen() to promises.

The router module

The router module, which is available in the@angular/router package, uses observables in router events and activated routes.

Router events

The router exposes eventsas observables. The router events allow you to intercept the navigation life cycle. The following list shows the sequence of router events:

  • NavigationStart
  • RouteConfigLoadStart
  • RouteConfigLoadEnd
  • RoutesRecognized
  • GuardsCheckStart
  • ChildActivationStart
  • ActivationStart
  • GuardsCheckEnd
  • ResolveStart
  • ResolveEnd
  • ActivationEnd
  • ChildActivationEnd
  • NavigationEnd
  • NavigationCancel
  • NavigationError
  • Scroll

    Note

    We recommend that you take a quick look athttps://angular.io/api/router/Event. Here, you can find further details about the events and their order.

To intercept all the events that the router goes through, first, you should inject theRouter service, which provides navigation and URL manipulation capabilities. Then, subscribe to theevents observable available in theRouter object, and filter the events of theRouterEvent type using therxjs filter operator.

This is an example of an Angular service that injects theRouter object in the constructor, subscribes to the router events, and just traces the event ID and path in the console. However, note that you can also introduce pretty much any specific behavior:

import { Injectable } from '@angular/core';import { Router, RouterEvent } from '@angular/router';import { filter } from 'rxjs/operators';@Injectable()export class CustomRouteService {  constructor(public router: Router) {    this.router.events.pipe(      filter(event => event instanceof RouterEvent)    ).subscribe((event: RouterEvent) => {      console.log(`The current event is : ${event.id} |                   event.url`);    });  }}

You can filter any specific event by putting the target type. The following code example only filters theNavigationStart event and traces the event ID and path inside the console. However, you can also introduce pretty much any specific behavior:

import { Injectable } from '@angular/core';import { NavigationStart, Router } from '@angular/router';import { filter } from 'rxjs/operators';@Injectable()export class CustomRouteService {  constructor(public router: Router) {    this.router.events.pipe(       filter(event => event instanceof NavigationStart)    ).subscribe((event: NavigationStart) => {      console.log(`The current event is : ${event.id} |                   event.url`);    });    } }

The majority of Angular applications have a routing mechanism. The router events change frequently over time, and it makes sense to listen to changes to execute the side effects. That's why observables are a flexible way in which to handle those streams.

The activated route

TheActivatedRoute class is a router service that you can inject into your components to retrieve information about a route's path and parameters. Many properties are based on observables. Here, you will find the contract (refers to the exposed methods and properties) of the activated route class:

class ActivatedRoute {  snapshot: ActivatedRouteSnapshot  url: Observable<UrlSegment[]>  params: Observable<Params>  queryParams: Observable<Params>  fragment: Observable<string | null>  data: Observable<Data>  outlet: string  component: Type<any> | string | null  routeConfig: Route | null  root: ActivatedRoute  parent: ActivatedRoute | null  firstChild: ActivatedRoute | null  children: ActivatedRoute[]  pathFromRoot: ActivatedRoute[]  paramMap: Observable<ParamMap>  queryParamMap: Observable<ParamMap>  toString(): string}

As you might havegathered,url,params,queryParams,fragment,data,paramMap, andqueryParamMap are represented as observables. Refer to the following list:

  • url: This is an observable that holds the URL of the active route.
  • params: This is an observable that holds the parameters of the active route.
  • queryParams: This is an observable that holds the query parameters shared by all of the routes.
  • fragment: This is an observable that holds the URL fragment shared by all the routes.
  • data: This is an observable that holds the static and resolved data of the active route.
  • paramMap: This is an observable that holds a map of the required parameters and the optional parameters of the active route.
  • queryParamMap: This is an observable that holds a map of the query parameters available to all the routes.

All these parameters might changeover time. Routes might share parameters, the parameters might have dynamic values, and it makes perfect sense to listen to those changes to register side effects or update the list of parameters.

Here's an example of an Angular component that injects theActivatedRoute class in the constructor and subscribes, in thengOnInit() method, to the following:

  • Theurl property ofactivatedRoute, logging the URL in the console
  • ThequeryParams property ofactivatedRoute in order to retrieve the parametercriteria and store it in a local property, namedcriteria:
    import { Component, OnInit } from '@angular/core';import { ActivatedRoute } from '@angular/router';@Component({  selector: 'app-recipes',  templateUrl: './recipes.component.html'})export class RecipesComponent implements OnInit {  criteria: any;  constructor(private activatedRoute: ActivatedRoute)   { }  ngOnInit() {    this.activatedRoute.url      .subscribe(url => console.log('The URL changed                                     to: ' + url));    this.activatedRoute.queryParams.subscribe(params     => {      this.processCriteria(params.criteria);    });  }  processCriteria(criteria: any) {    this.criteria = criteria;  }}

Reactive forms

Reactive formsavailable under the@angular/forms package are based on observables to track form control changes. Here's the contract of theFormControl class in Angular:

class FormControl extends AbstractControl { //other properties here  valueChanges: Observable<any> statusChanges: Observable<any>}

TheFormControl properties ofvalueChanges andstatusChanges are represented as observables that trigger change events. Subscribing to aFormControl value change is a way of triggering application logic within thecomponent class.

Here's an example of an Angular component that subscribes to thevalueChanges of aFormControl property calledratingand simply traces the value throughconsole.log(value). In this way, each time, you will get the changed value as an output:

import { Component, OnInit } from '@angular/core';import { FormGroup } from '@angular/forms';@Component({  selector: 'app-recipes',  templateUrl: './recipes.component.html'})export class MyComponent implements OnInit {  form!: FormGroup;  ngOnInit() {    const ratingControl = this.form.get('rating');    ratingControl?.valueChanges.subscribe(      (value) => {        console.log(value);      }    );  }}

The event emitter

The event emitter, which ispart of the@angular/core package, is used to emit data from a child component to a parent component through the@Output() decorator. TheEventEmitter class extends the RxJS subject and registers handlers for events emitted by this instance:

class EventEmitter<T> extends Subject {  constructor(isAsync?: boolean): EventEmitter<T>  emit(value?: T): void  subscribe(next?: (value: T) => void, error?: (error: any)   => void, complete?: () => void): Subscription}

This is what happens under the hood when you create an event emitter and emit a value.

The following is an example of an Angular component that emits the updated value of a recipe rating:

import { Component, Output } from '@angular/core';import { EventEmitter } from 'events'; @Component({  selector: 'app-recipes',  templateUrl: './recipes.component.html'  })export class RecipesComponent {  constructor() {}  @Output() updateRating = new EventEmitter();  updateRecipe(value: string) {    this.updateRating.emit(value);  }}

The async pipe

Here,AsyncPipe automatically subscribes to an observable when used in a component's template andemits the latest value each time. This avoids subscribing logic in the component and helps with binding and updating your asynchronous streams data in the template. In this example, we are using an async pipe insidengIf. Thisdiv tag will only be rendered when thedata$ variable emits something:

  <div *ngIf="data$ | async"></div>

We will cover the advantages and usage of async pipes inChapter 4,Fetching Data as Streams.

Note

In the previous code snippets, the subscription to the observables was done explicitly for demonstration purposes. In a real-world example, we should include the unsubscription logic if we use an explicit subscription. We will shed light on this inChapter 4,Fetching Data as Streams.

Now that we have learned about the advantages of using RxJS in Angular and how it makes dealing with some concepts smoother, let's explore the marble diagram, which is very handy for understanding and visualizing the observable execution.

Learning about the marble diagram – our secret weapon

RxJS ships withmore than 100operators. Operators are one of the building blocks of RxJS. They are very useful for manipulating streams. All the reactive patterns that will be detailed later in this book are based on operators. And when it comes to explaining operators, it is better to refer to a visual representation. And that's why there are marble diagrams. Thankfully!

Marble diagrams are a visual representation of the operator's execution. We will be using the marble diagram in all chapters to understand the behavior of RxJS operators. At first, it might seem daunting, but it is delightfully simple. First, you only have to understand the anatomy of the diagram and then you're good to read and translate it. You will be able to understand any RxJS operator – those used in this book along with others, too.

So as we said, marble diagrams represent the execution of an operator. So, every diagram will include the following:

  • Input Observable(s): This represents oneor many observables given as input to the operator.
  • Operator: This represents the operator tobe executed with its parameters.
  • Output Observable: This represents the observable produced after the operator's execution:
Figure 1.2 – The operator execution

Figure 1.2 – The operator execution

Well, this is the big picture. Now, let's zoom in on the representation of the input/output observables. It includes the following:

  • The timeline: Observables areasynchronous streams that produce data over time. Therefore, the representation of time is crucial in the marble diagram, and it is represented as an arrow flowing from left to right.
  • The marble values: These are thevalues emitted by the observables over time.
  • The completion status: The vertical line represents the successful completion of the observables.
  • The error status: The X represents anerror emitted by the observable. Neither values nor the vertical line representing the completion will be emitted thereafter:
Figure 1.3 – Elements of the marble diagram

Figure 1.3 – Elements of the marble diagram

That's all the elements you need to know. Now, let's put all of the pieces together into a real marble diagram:

Figure 1.4 – An example of a marble diagram for a custom operator

Figure 1.4 – An example of a marble diagram for a custom operator

Let's break down what is happening in the preceding diagram. As you might have guessed, we have a custom operator calleddivideByTwo that will emit half of every received number. When the input observable emits the values of4 and8, the output observable produces2 and4, respectively.

However, when the value ofR, which is non-numeric, is emitted, then an error is thrown, indicating abnormal termination. This case is not handled in the operator code. The input observable continues the emission and then completes successfully. However, the value willnever be processed because, after the error, the stream is closed.

At this level, we went through all of the elements composing the marble diagram. And you will be able to understand the operators used in the chapters to come.

Summary

In this chapter, we walked you through the fundamentals of reactive programming and which use cases it shines in. Then, we highlighted the use of reactive programming in Angular by illustrating concrete examples, implementations, and advantages. Finally, we explained the marble diagram, which will be our reference to explain RxJS operators in all the following chapters. In the next chapter, we will focus on RxJS 7's new features as we will be using this version of RxJS.

Left arrow icon

Page1 of 6

Right arrow icon
Download code iconDownload Code

Key benefits

  • 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

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.

Who is this book 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.

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

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date :Apr 29, 2022
Length:224 pages
Edition :1st
Language :English
ISBN-13 :9781801814225
Languages :
Tools :

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
Product feature iconAI Assistant (beta) to help accelerate your learning

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Product Details

Publication date :Apr 29, 2022
Length:224 pages
Edition :1st
Language :English
ISBN-13 :9781801814225
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99billed monthly
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconSimple pricing, no contract
€189.99billed annually
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick iconExclusive print discounts
€264.99billed in 18 months
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick iconExclusive print discounts

Frequently bought together


Angular Cookbook
Angular Cookbook
Read more
Aug 2021652 pages
Full star icon4.4 (14)
eBook
eBook
€8.98€23.99
€29.99
Reactive Patterns with RxJS for Angular
Reactive Patterns with RxJS for Angular
Read more
Apr 2022224 pages
Full star icon4.1 (15)
eBook
eBook
€8.98€32.99
€41.99
Full Stack Development with Angular and GraphQL
Full Stack Development with Angular and GraphQL
Read more
Mar 2022390 pages
Full star icon4.2 (6)
eBook
eBook
€8.98€24.99
€30.99
Stars icon
Total102.97
Angular Cookbook
€29.99
Reactive Patterns with RxJS for Angular
€41.99
Full Stack Development with Angular and GraphQL
€30.99
Total102.97Stars icon
Buy 2+ to unlock€6.99 prices - master what's next.
SHOP NOW

Table of Contents

18 Chapters
Part 1 – IntroductionChevron down iconChevron up icon
Part 1 – Introduction
Chapter 1: The Power of the Reactive ParadigmChevron down iconChevron up icon
Chapter 1: The Power of the Reactive Paradigm
Technical requirements
Exploring the pillars of reactive programming
Using RxJS in Angular and its advantages
Learning about the marble diagram – our secret weapon
Summary
Chapter 2: RxJS 7 – The Major FeaturesChevron down iconChevron up icon
Chapter 2: RxJS 7 – The Major Features
Technical requirements
Exploring the bundle size improvements
Reviewing the TypeScript typing improvements
Understanding the toPromise() deprecation
Highlighting API consistency improvements
Summary
Chapter 3: A Walkthrough of the ApplicationChevron down iconChevron up icon
Chapter 3: A Walkthrough of the Application
Technical requirements
Our app's user stories
Our app's architecture
The components overview
Summary
Part 2 – A Trip into Reactive PatternsChevron down iconChevron up icon
Part 2 – A Trip into Reactive Patterns
Chapter 4: Fetching Data as StreamsChevron down iconChevron up icon
Chapter 4: Fetching Data as Streams
Technical requirements
Defining the requirement
Exploring the classic pattern for fetching data
Exploring the reactive pattern for fetching data
Highlighting the advantages of the reactive pattern
Summary
Chapter 5: Error HandlingChevron down iconChevron up icon
Chapter 5: Error Handling
Technical requirements
Understanding the anatomy of an Observable
Exploring error handling patterns and strategies
Error handling in action
Summary
Chapter 6: Combining StreamsChevron down iconChevron up icon
Chapter 6: Combining Streams
Technical requirements
Defining the requirement
Exploring the imperative pattern for filtering data
Exploring the declarative pattern for filtering data
Summary
Chapter 7: Transforming StreamsChevron down iconChevron up icon
Chapter 7: Transforming Streams
Technical requirements
Defining the requirement
Exploring the imperative pattern for autosave
Exploring the reactive pattern for autosave
Learning about other useful higher-order mapping operators
Summary
Part 3 – Multicasting Takes You to New PlacesChevron down iconChevron up icon
Part 3 – Multicasting Takes You to New Places
Chapter 8: Multicasting EssentialsChevron down iconChevron up icon
Chapter 8: Multicasting Essentials
Technical requirements
Explaining Multicasting versus Unicasting
Exploring Subjects
Highlighting Multicasting operators
Summary
Chapter 9: Caching StreamsChevron down iconChevron up icon
Chapter 9: Caching Streams
Technical requirements
Defining the requirement
Learning about using the reactive pattern to cache streams
Exploring the RxJS 7 recommended pattern to cache streams
Highlighting the use cases of caching streams
Summary
Chapter 10: Sharing Data between ComponentsChevron down iconChevron up icon
Chapter 10: Sharing Data between Components
Technical requirements
Defining the requirement
Exploring the reactive pattern to share data
Highlighting other ways for sharing data
Summary
Chapter 11: Bulk OperationsChevron down iconChevron up icon
Chapter 11: Bulk Operations
Technical requirements
Defining the requirement
Learning about the reactive pattern for bulk operations
Learning about the reactive pattern for tracking progress
Summary
Chapter 12: Processing Real-Time UpdatesChevron down iconChevron up icon
Chapter 12: Processing Real-Time Updates
Technical requirements
Defining the requirement
Learning the reactive pattern for consuming real-time messages
Learning the reactive pattern for handling reconnection
Summary
Part 4 – Final TouchChevron down iconChevron up icon
Part 4 – Final Touch
Chapter 13: Testing RxJS ObservablesChevron down iconChevron up icon
Chapter 13: Testing RxJS Observables
Technical requirements
Learning about the subscribe and assert pattern
Learning about the marble testing pattern
Highlighting testing streams using HttpClientTestingModule
Summary
Why subscribe?
Other Books You May EnjoyChevron down iconChevron up icon
Other Books You May Enjoy
Packt is searching for authors like you
Share Your Thoughts

Recommendations for you

Left arrow icon
Full-Stack Flask and React
Full-Stack Flask and React
Read more
Oct 2023408 pages
Full star icon3.8 (5)
eBook
eBook
€8.98€23.99
€29.99
C# 13 and .NET 9 – Modern Cross-Platform Development Fundamentals
C# 13 and .NET 9 – Modern Cross-Platform Development Fundamentals
Read more
Nov 2024828 pages
Full star icon4.3 (4)
eBook
eBook
€8.98€35.99
€44.99
Real-World Web Development with .NET 9
Real-World Web Development with .NET 9
Read more
Dec 2024578 pages
Full star icon3.5 (4)
eBook
eBook
€8.98€29.99
€37.99
Django 5 By Example
Django 5 By Example
Read more
Apr 2024826 pages
Full star icon4.6 (36)
eBook
eBook
€8.98€29.99
€37.99
React and React Native
React and React Native
Read more
Apr 2024518 pages
Full star icon4.2 (9)
eBook
eBook
€8.98€26.99
€32.99
Scalable Application Development with NestJS
Scalable Application Development with NestJS
Read more
Jan 2025614 pages
Full star icon4.5 (6)
eBook
eBook
€8.98€23.99
€29.99
C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals
C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals
Read more
Nov 2023828 pages
Full star icon4.3 (61)
eBook
eBook
€8.98€35.99
€44.99
Responsive Web Design with HTML5 and CSS
Responsive Web Design with HTML5 and CSS
Read more
Sep 2022504 pages
Full star icon4.5 (56)
eBook
eBook
€8.98€35.99
€44.99
Modern Full-Stack React Projects
Modern Full-Stack React Projects
Read more
Jun 2024506 pages
Full star icon4.8 (9)
eBook
eBook
€8.98€26.99
€33.99
Learning Angular
Learning Angular
Read more
Jan 2025494 pages
Full star icon4.1 (7)
eBook
eBook
€8.98€26.99
€33.99
Right arrow icon

Customer reviews

Top Reviews
Rating distribution
Full star iconFull star iconFull star iconFull star iconHalf star icon4.1
(15 Ratings)
5 star53.3%
4 star26.7%
3 star0%
2 star13.3%
1 star6.7%
Filter icon Filter
Top Reviews

Filter reviews by




xinyuOct 16, 2023
Full star iconFull star iconFull star iconFull star iconFull star icon5
Chapter 12: Processing Real-Time UpdatesHandling errors// Push errors to the serversubject$.error('Something wrong happens')// Handle incoming errors from the serversubject$.error('Something wrong happens')here is a mistake. please fix it.thanks
Subscriber reviewPackt
Zeeshan SiddiquiOct 11, 2022
Full star iconFull star iconFull star iconFull star iconFull star icon5
Learning Reactive Patterns is challenging at times. The book is a good read and it goes step by step introducing operators, their syntax, purpose, usage and examples. Then in the later chapters it takes that knowledge and builds on how they can be used in real world scenarios. After going through the examples and use cases, I immediately found some instances in my project at work where I could make improvements. Marble testing was also introduced in a clear and concise way.Must read. Highly recommended.
Amazon Verified reviewAmazon
NikeshAug 05, 2022
Full star iconFull star iconFull star iconFull star iconFull star icon5
Amazon Verified reviewAmazon
M. CoatneyJun 21, 2022
Full star iconFull star iconFull star iconFull star iconFull star icon5
Im a professional Angular developer with 5 yrs Angular experience and 18 yrs programming. I dont usually buy programming books teaching frameworks or languages anymore. And I already use NG reactive patterns... but this book would have made my journey to understanding them A LOT faster...I feel this is written for the pro. It doesnt waste time. Advanced topics are well explained and sufficiently thorough.
Amazon Verified reviewAmazon
PreethiApr 29, 2022
Full star iconFull star iconFull star iconFull star iconFull star icon5
I read the book and it looks great, learning reactive patterns with rxjs is part of my career growth in angular. I felt this book helped me in understanding the reactive programming and also with real time scenarios. I recommend this books for the people who are interested in learning angular with reactive programming.
Amazon Verified reviewAmazon
  • Arrow left icon Previous
  • 1
  • 2
  • 3
  • Arrow right icon Next

People who bought this also bought

Left arrow icon
C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals
C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals
Read more
Nov 2023828 pages
Full star icon4.3 (61)
eBook
eBook
€8.98€35.99
€44.99
Responsive Web Design with HTML5 and CSS
Responsive Web Design with HTML5 and CSS
Read more
Sep 2022504 pages
Full star icon4.5 (56)
eBook
eBook
€8.98€35.99
€44.99
React and React Native
React and React Native
Read more
May 2022606 pages
Full star icon4.6 (17)
eBook
eBook
€8.98€29.99
€37.99
€32.99
Building Python Microservices with FastAPI
Building Python Microservices with FastAPI
Read more
Aug 2022420 pages
Full star icon4 (8)
eBook
eBook
€8.98€28.99
€35.99
Right arrow icon

About the author

Profile icon Lamis Chebbi
Lamis Chebbi
LinkedIn icon
Lamis Chebbi is a Google Developer Expert for Angular. She is the author of “Reactive Patterns with RxJS for Angular”. She is an enthusiastic software engineer with a strong passion for the modern web. She's the founder of Angular Tunisia, a member of the WWCode community, a speaker, a content creator, and a trainer. She has been into Angular for the past few years and loves to share her knowledge about Angular through participating in workshops and organizing training sessions. Empowering women and students is one of her highest priorities. Besides Angular and the web, Lamis loves music, traveling, chromotherapy, and volunteering. Last but not least, she's a forever student.
Read more
See other products by Lamis Chebbi
Getfree access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook?Chevron down iconChevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website?Chevron down iconChevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook?Chevron down iconChevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support?Chevron down iconChevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks?Chevron down iconChevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook?Chevron down iconChevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.

Create a Free Account To Continue Reading

Modal Close icon
OR
    First name is required.
    Last name is required.

The Password should contain at least :

  • 8 characters
  • 1 uppercase
  • 1 number
Notify me about special offers, personalized product recommendations, and learning tips By signing up for the free trial you will receive emails related to this service, you can unsubscribe at any time
By clicking ‘Create Account’, you are agreeing to ourPrivacy Policy andTerms & Conditions
Already have an account? SIGN IN

Sign in to activate your 7-day free access

Modal Close icon
OR
By redeeming the free trial you will receive emails related to this service, you can unsubscribe at any time.

[8]ページ先頭

©2009-2025 Movatter.jp