Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Reactive Patterns with RxJS for Angular

You're reading from   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
Product type Paperback
Published in Apr 2022
Publisher Packt
ISBN-13 9781801811514
Length 224 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Lamis Chebbi Lamis Chebbi
Author Profile Icon Lamis Chebbi
Lamis Chebbi
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Part 1 – Introduction
2. Chapter 1: The Power of the Reactive Paradigm FREE CHAPTER 3. Chapter 2: RxJS 7 – The Major Features 4. Chapter 3: A Walkthrough of the Application 5. Part 2 – A Trip into Reactive Patterns
6. Chapter 4: Fetching Data as Streams 7. Chapter 5: Error Handling 8. Chapter 6: Combining Streams 9. Chapter 7: Transforming Streams 10. Part 3 – Multicasting Takes You to New Places
11. Chapter 8: Multicasting Essentials 12. Chapter 9: Caching Streams 13. Chapter 10: Sharing Data between Components 14. Chapter 11: Bulk Operations 15. Chapter 12: Processing Real-Time Updates 16. Part 4 – Final Touch
17. Chapter 13: Testing RxJS Observables 18. Other Books You May Enjoy

Learning the reactive pattern for consuming real-time messages

RxJS has a special type of Subject called WebSocketSubject that allows you to communicate with a WebSocket server. Let's learn about the behavior of this Subject and its capabilities.

The WebSocketSubject behavior

WebSocketSubject is nothing but a wrapper around the W3C WebSocket object available in the browser. It allows us to both send and consume data through a WebSocket connection.

The WebSocketSubject creation

In order to use WebSocketSubject, you have to call the webSocket factory function that produces this special type of Subject and takes the endpoint of your WebSocket server as input. The following is the function signature:

webSocket<T>(urlConfigOrSource: string | WebSocketSubjectConfig<T>): WebSocketSubject<T>;

It accepts two types of arguments: either a string representing the URL of your endpoint or a special object of the WebSocketSubjectConfig type that contains the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime