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
Mex$1128.99
Full star iconFull star iconFull star iconFull star iconHalf star icon4.1(15 Ratings)
PaperbackApr 2022224 pages1st Edition
eBook
Mex$180 Mex$902.99
Paperback
Mex$1128.99
Subscription
Free Trial
Arrow left icon
Profile Icon Lamis Chebbi
Arrow right icon
Mex$1128.99
Full star iconFull star iconFull star iconFull star iconHalf star icon4.1(15 Ratings)
PaperbackApr 2022224 pages1st Edition
eBook
Mex$180 Mex$902.99
Paperback
Mex$1128.99
Subscription
Free Trial
eBook
Mex$180 Mex$902.99
Paperback
Mex$1128.99
Subscription
Free Trial

What do you get with Print?

Product feature iconInstant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
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

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery feeDeliver to Mexico

Standard delivery10 - 13 business days

Mex$149.95

Premium delivery3 - 6 business days

Mex$299.95
(Includes tracking information)

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 :9781801811514
Languages :
Tools :

What do you get with Print?

Product feature iconInstant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery feeDeliver to Mexico

Standard delivery10 - 13 business days

Mex$149.95

Premium delivery3 - 6 business days

Mex$299.95
(Includes tracking information)

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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 Mex$85 each
Feature tick iconExclusive print discounts
$279.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 Mex$85 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
Mex$180Mex$639.99
Mex$799.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
Mex$180Mex$902.99
Mex$1128.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
Mex$180Mex$689.99
Mex$861.99
Stars icon
TotalMex$2,790.97
Angular Cookbook
Mex$799.99
Reactive Patterns with RxJS for Angular
Mex$1128.99
Full Stack Development with Angular and GraphQL
Mex$861.99
TotalMex$2,790.97Stars icon
Buy 2+ to unlockMex$145 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
Mex$180Mex$656.99
Mex$820.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
Mex$180Mex$984.99
Mex$1230.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
Mex$180Mex$820.99
Mex$1025.99
Django 5 By Example
Django 5 By Example
Read more
Apr 2024826 pages
Full star icon4.6 (36)
eBook
eBook
Mex$180Mex$820.99
Mex$1025.99
React and React Native
React and React Native
Read more
Apr 2024518 pages
Full star icon4.2 (9)
eBook
eBook
Mex$180Mex$721.99
Mex$902.99
Scalable Application Development with NestJS
Scalable Application Development with NestJS
Read more
Jan 2025614 pages
Full star icon4.5 (6)
eBook
eBook
Mex$180Mex$656.99
Mex$820.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
Mex$180Mex$984.99
Mex$1230.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
Mex$180Mex$984.99
Mex$1230.99
Modern Full-Stack React Projects
Modern Full-Stack React Projects
Read more
Jun 2024506 pages
Full star icon4.8 (9)
eBook
eBook
Mex$180Mex$738.99
Mex$922.99
Learning Angular
Learning Angular
Read more
Jan 2025494 pages
Full star icon4.1 (7)
eBook
eBook
Mex$180Mex$738.99
Mex$922.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
Mex$180Mex$984.99
Mex$1230.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
Mex$180Mex$984.99
Mex$1230.99
React and React Native
React and React Native
Read more
May 2022606 pages
Full star icon4.6 (17)
eBook
eBook
Mex$180Mex$820.99
Mex$1025.99
Mex$902.99
Building Python Microservices with FastAPI
Building Python Microservices with FastAPI
Read more
Aug 2022420 pages
Full star icon4 (8)
eBook
eBook
Mex$180Mex$771.99
Mex$963.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

What is the digital copy I get with my Print order?Chevron down iconChevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book?Chevron down iconChevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium:Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge?Chevron down iconChevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order?Chevron down iconChevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries:www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges?Chevron down iconChevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live inMexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live inTurkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order?Chevron down iconChevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy?Chevron down iconChevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged?Chevron down iconChevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use?Chevron down iconChevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books?Chevron down iconChevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium:Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela

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