29,99 €
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.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 190
Veröffentlichungsjahr: 2022
A practical guide to managing your Angular application's data reactively and efficiently using RxJS 7
Lamis Chebbi
BIRMINGHAM—MUMBAI
Reactive Patterns with RxJS for Angular
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Associate Group Product Manager: Pavan Ramchandani
Publishing Product Manager: Ashitosh Gupta
Senior Editor: Mark Dsouza
Content Development Editor: Divya Vijayan
Technical Editor: Shubham Sharma
Copy Editor: Safis Editing
Project Coordinator: Ajesh Devavaram
Proofreader: Safis Editing
Indexer: Rekha Nair
Production Designer: Alishon Mendonca
Marketing Coordinator: Elizabeth Varghese
First published: April 2022
Production reference: 3200924
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80181-151-4
www.packt.com
To my father, who taught me diligence, perseverance, and work ethic. Thank you for always being there to support me and lift me up.
To my mother, who taught me selflessness and doing things with love. Thank you for your enduring encouragement during the writing of this book.
To my brother and my sisters, for their continuous support.
-Lamis Chebbi
Lamis Chebbi is a Google Developer Expert for Angular and an Auth0 ambassador.
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. ng-girls is one of the communities she supports. 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.
I want to thank all the people that believed in me and supported me.
I am thankful for the people who helped me in the journey.
I am thankful for the people who inspired me in the journey.
Dave Muellerchen is a freelancer. He loves sharing his self-taught knowledge of JavaScript at meetups and conferences.
His passion for communities shows in his commitment to them. He is the organizer of the Angular Hamburg Meetup and Tech Meetup Hamburg. He is also a team member at the Angular conference in Germany (ng-de) and a Google Developer Expert for web technologies. He streams developer content on Twitch.
Thanks to my wife, who has my back to do what I do. Thank you my sons, for the fun and the distraction. And of course, thank you Lamis for your trust.
Anu Nagan G has worked in various corporate organizations starting from SaaS startup [GenDeep], midsize [GAVS], Fortune 500 companies [DXC] playing various roles there such as Technical Product Manager, Full Stack Product Lead [Angular, Java, Python, AWS], Delivery Lead respectively in his 8 years of tenure. Currently, he is with Bounteous, leading parallel projects such as Clinical mobile app development, Fintech marketing data migration. Contributed to various AIOps products ZIF, Anu Nagan G has worked in various corporate organizations starting from SaaS startup [GenDeep], midsize [GAVS], Fortune 500 companies [DXC] playing various roles there such as Technical Product Manager, Full Stack Product Lead [Angular, Java, Python, AWS], Delivery Lead respectively in his 8 years of tenure. Currently, he is with Bounteous, leading parallel projects such as Clinical mobile app development, Fintech marketing data migration. Contributed to various AIOps products ZIF, Gcare in the past. He is an avid reader, cinephile, who loves to play Guitar, makes short films with his friends.
I would like to dedicate this to my grandparents who are celebrating their 82nd anniversary, to my wife and we are expecting. Happy birthday Hema.
Muhammad Awais is an internationally recognized Lead Software Engineer and Full Stack Developer with over 9 years of experience. His expertise spans JavaScript, TypeScript, Angular, React, Vue, NodeJS, and AI, focusing on crafting exceptional web experiences and solving complex bugs.
Awais has authored articles on Generative AI and JavaScript for leading publications like Generative AI and JavaScript in Plain English. He is also a renowned speaker, having represented Google and AWS at various events globally. He has gained international recognition from Google, AWS, Postman, and others for his contributions to the tech community.
Switching to a reactive mindset is one of the biggest challenges when you start learning Reactive programming using RxJS. I believe that the reactive mindset is gradually achieved by learning reactive patterns and comparing the reactive way with the imperative one to distinguish the difference and the benefits.
That's why I wrote this book, which gathers a set of reactive patterns applied in an Angular application. Learning reactive patterns helps with managing your application's data efficiently, writing clean and maintainable code, reacting to user changes faster, and consequently, enhancing the user experience.
So, all that you have to do is get started!
The book is for Angular developers who want to use RxJS to build reactive web applications. This book assumes beginner-level knowledge of and experience with Angular, RxJS, TypeScript, and functional programming concepts.
Chapter 1, The Power of the Reactive Paradigm, explains the fundamentals of Reactive programming.
Chapter 2, RxJS 7 – The Major Features, focuses on the main improvements of RxJS 7.
Chapter 3, A Walkthrough of the Application, highlights the architecture and requirements of the application that we will be building gradually.
Chapter 4, Fetching Data as Streams, explains the first reactive pattern for fetching data.
Chapter 5, Error Handling, details the error handling strategies and the reactive patterns for handling errors.
Chapter 6, Combining Streams, explains the reactive pattern for combining streams.
Chapter 7, Transforming Streams, explains the reactive pattern for transforming streams.
Chapter 8, Multicasting Essentials, focuses on the multicasting approach essentials.
Chapter 9, Caching Streams, explains the reactive pattern for caching streams.
Chapter 10, Sharing Data between Components, explains the reactive patterns for sharing data between components.
Chapter 11, Bulk Operations, explores the reactive pattern for performing bulk actions.
Chapter 12, Processing Real-Time Updates, explores the reactive pattern for consuming real-time updates.
Chapter 13, Testing RxJS Observables, explains the different strategies for testing reactive patterns.
All code examples have been tested using Angular 12 on a Windows operating system. However, it should work with future releases too.
Please make sure you follow the prerequisites at https://angular.io/guide/setup-local. The prerequisites include the environment setup and the technologies needed in order to install and use Angular.
We also used the Bootstrap library to manage the application responsiveness. We used primeng as a library of rich components and RxJS 7 as the reactive library, of course.
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book's GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Reactive-Patterns-with-RxJS-for-Angular. If there's an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781801811514_ColorImages.pdf.
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "In the try block, you place your risky statements, and inside catch, you handle the possible exceptions."
A block of code is set as follows:
behaviourSubject$.subscribe({
next: (message) => console.log(message),
error: (error) => console.log(error),
complete: () => console.log('Stream Completed'),
});
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
behaviourSubject$.subscribe({
next: (message) => console.log(message),
error: (error) => console.log(error),
complete: () => console.log('Stream Completed'),
});
Any command-line input or output is written as follows:
$ mkdir css
$ cd css
Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: "Select System info from the Administration panel."
Tips or Important Notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Once you've read Reactive Patterns with RxJS for Angular, we'd love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we're delivering excellent quality content.
In this section, you will understand the importance of using the reactive paradigm in an Angular application, as well as the new features of RxJS 7. In the third chapter, we will introduce the application that we are going to progressively build as we go through the book.
This part comprises the following chapters:
Chapter 1, The Power of the Reactive ParadigmChapter 2, RxJS 7 – The Major FeaturesChapter 3, A Walkthrough of the Application