SlideShare a Scribd company logo
4
Most read
6
Most read
11
Most read
Presented By:
Kiran & Aanchal
Observables in
Angular
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Join the session 5 minutes prior to
the session start time. We start on
time and conclude on time!
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Silent Mode
Keep your mobile devices in silent
mode, feel free to move out of
session in case you need to attend
an urgent call.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
Our Agenda
01 Introduction to Observables
02 Defining Observers
03 Subscribing and Unsubscribing
04 Rxjs
05 Some Rxjs operators
Why do we need Observables?
● Angular makes use of observables as an interface to handle a variety of common
asynchronous operations.
● Observables provide support for passing messages between parts of your application.
● The observer pattern is a software design pattern in which an object, called the subject,
maintains a list of its dependents, called observers, and notifies them automatically of state
changes.
● For example: The HTTP module uses observables to handle AJAX requests and responses.
What are Observables?
● Observable in Angular is a feature that provides support for delivering messages between
different parts of your single-page application.
● This feature is frequently used in Angular because it is responsible for handling multiple
values, asynchronous programming in Javascript, and also event handling processes.
● Observables is a new primitive type which acts as a blueprint for how we want to create
streams, subscribe to them, react to new values, and combine streams together to build
new ones.
● Observables are declarative —that is, you define a function for publishing values, but it is
not executed until a consumer subscribes to it. The subscribed consumer then receives
notifications until the function completes, or until they unsubscribe.
Observables in Angular
Promise vs Observables
● Emitting Values: An Observable can emit multiple values. On the other hand, Promises emit
only a single value.
● Cancelable Subscriptions in Observable: We have a subscription that can be canceled in
Observables but Promises cannot be canceled. The subscription allows us to stop the
listener from receiving more values.
● Lazy & Eager: Observables are considered as lazy as they are not executed until we
subscribe to them and Promises are not lazy because they execute after the creation. We
need not subscribe to promises. Promises are executed eagerly while Observables are
executed lazily.
Observer & Observables
● Observers allow you to "push" new data into an observable sequence whereas An
Observable is what we can use to listen, to new changes that are emitted by an Observer.
● Real-time usage of Observable and Observer
- While receiving response from AJAX
- While performing large tasks in client(browser)
Observables in Angular
Creating Observers
● In order to show how subscribing works, we need to create a new observable. There is a
constructor that you use to create new instances, but for illustration, we can use some
methods from the RxJS library that create simple observables of frequently used types:
Execution of Observables
● Next: The observer sends a value, which might be a number, string, or object, with each
consecutive value.
● Error: If an error occurs in the Observable, no additional data may be sent to the
Observable.
● Complete: The observer does not send any value, therefore the value is complete. This
often indicates that the subscription to a certain Observable has been completed.
● Destroying an Observable: It simply means unsubscribing from it and removing it from the
DOM.
What is RxJs?
● RxJS (Reactive Extensions for JavaScript) is a library for reactive programming using
observables that makes it easier to compose asynchronous or callback-based code.
● The library also provides utility functions for creating and working with observables. These
utility functions can be used for:
➢ Converting existing code for async operations into observables
➢ Iterating through the values in a stream
➢ Mapping values to different types
➢ Filtering streams
➢ Composing multiple streams
…RxJs
When to use RxJS?
If your project consists of lots of async task handling than RxJS is a good choice.
Advantages of using RxJS
● RxJS can be used with other Javascript libraries and frameworks.
● RxJS is an awesome library when it comes to the handling of async tasks.
● RxJS offers a huge collection of operators in mathematical, transformation, filtering, error
handling, join categories that makes life easy when used with reactive programming.
Disadvantages of using RxJS
● Debugging the code with observables is little difficult.
RxJs Operators
● map - map operator is a transformation operator used to transform the items emitted by an
Observable by applying a function to each item.
● take - emits only the first count values emitted by the source Observable
● takeWhile - passes values from the source observable to the observer as long as the
function known as the predicate returns true.
● skip - it allows you to ignore the first x emissions from the source
● filter - filter items emitted by the source Observable by only emitting those that satisfy a
specified predicate.
What is Memory Leak?
● A memory leak is a type of resource leak caused by poor management of memory
allocation in a way that is not cleared from the memory when is not needed anymore.
● The memory leak is one of the worst problems developers could have since it is very
difficult to debug and catch.
● This would lead to slow performance or even a crashing application.
● Most often memory leaks are caused due to bad management of Observables.
● There are certain ways to avoid it. You can use Angular async pipe or you can unsubscribe
properly from observable.
DEMO
References
● https://angular.io/guide/observables
● https://www.learnrxjs.io/learn-rxjs/operators
● https://www.tektutorialshub.com/angular/rxjs-observable-using-create-of-from-i
n-angular/
● https://luukgruijs.medium.com/understanding-creating-and-subscribing-to-obse
rvables-in-angular-426dbf0b04a3
● https://www.tutorialspoint.com/rxjs/rxjs_overview.htm
Thank You !
Get in touch with us:
Lorem Studio, Lord Building
D4456, LA, USA

More Related Content

PDF
Spring Boot Interview Questions | Edureka
PPTX
Kotlin for Android App Development Presentation
PDF
TypeScript Best Practices
PPTX
Modern JS with ES6
PPTX
TypeScript Overview
PDF
Introduction to RxJS
PPTX
Sharing Data Between Angular Components
PDF
Angular 16 – the rise of Signals
Spring Boot Interview Questions | Edureka
Kotlin for Android App Development Presentation
TypeScript Best Practices
Modern JS with ES6
TypeScript Overview
Introduction to RxJS
Sharing Data Between Angular Components
Angular 16 – the rise of Signals

What's hot (20)

PDF
Angular & RXJS: examples and use cases
PDF
Angular Observables & RxJS Introduction
PPTX
JavaScript Promises
PPT
Postman.ppt
PPTX
Node js introduction
PDF
Ngrx slides
PPTX
PPTX
Introduction to RxJS
PDF
gRPC Overview
PDF
Swagger With REST APIs.pptx.pdf
PPTX
An Introduction To REST API
PPTX
Json Web Token - JWT
PDF
Getting Started with NgRx (Redux) Angular
PDF
Angular and The Case for RxJS
PPTX
React with Redux
PPTX
Top 10 RxJs Operators in Angular
PDF
An Introduction to Redux
PDF
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
PDF
React & GraphQL
PDF
Introduction to Node JS.pdf
Angular & RXJS: examples and use cases
Angular Observables & RxJS Introduction
JavaScript Promises
Postman.ppt
Node js introduction
Ngrx slides
Introduction to RxJS
gRPC Overview
Swagger With REST APIs.pptx.pdf
An Introduction To REST API
Json Web Token - JWT
Getting Started with NgRx (Redux) Angular
Angular and The Case for RxJS
React with Redux
Top 10 RxJs Operators in Angular
An Introduction to Redux
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
React & GraphQL
Introduction to Node JS.pdf
Ad

Similar to Observables in Angular (20)

PPTX
RxJS In-Depth - AngularConnect 2015
PPTX
Rxjs swetugg
PPTX
Rxjs marble-testing
PPTX
RxJS and Reactive Programming - Modern Web UI - May 2015
PPTX
Functional Reactive Programming (FRP): Working with RxJS
PPTX
Rx – reactive extensions
PPTX
Angular2 rxjs
PPTX
Rxjs ngvikings
PDF
My Gentle Introduction to RxJS
PDF
Angular 2 observables
PDF
RxJS101 - What you need to know to get started with RxJS tomorrow
PDF
Reactive x
PDF
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
PDF
rx.js make async programming simpler
PDF
Rxjs kyivjs 2015
PDF
RxJS - The Reactive extensions for JavaScript
PPTX
Angular observables for fun and profit
PPTX
Luis Atencio on RxJS
PDF
Reactive programming and RxJS
PPTX
Promises, promises, and then observables
RxJS In-Depth - AngularConnect 2015
Rxjs swetugg
Rxjs marble-testing
RxJS and Reactive Programming - Modern Web UI - May 2015
Functional Reactive Programming (FRP): Working with RxJS
Rx – reactive extensions
Angular2 rxjs
Rxjs ngvikings
My Gentle Introduction to RxJS
Angular 2 observables
RxJS101 - What you need to know to get started with RxJS tomorrow
Reactive x
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
rx.js make async programming simpler
Rxjs kyivjs 2015
RxJS - The Reactive extensions for JavaScript
Angular observables for fun and profit
Luis Atencio on RxJS
Reactive programming and RxJS
Promises, promises, and then observables
Ad

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
PPTX
Self-Healing Test Automation Framework - Healenium
PPTX
Kanban Metrics Presentation (Project Management)
PPTX
Java 17 features and implementation.pptx
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
PPTX
GraalVM - A Step Ahead of JVM Presentation
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
DAPR - Distributed Application Runtime Presentation
PPTX
Introduction to Azure Virtual WAN Presentation
PPTX
Introduction to Argo Rollouts Presentation
PPTX
Intro to Azure Container App Presentation
PPTX
Insights Unveiled Test Reporting and Observability Excellence
PPTX
Introduction to Splunk Presentation (DevOps)
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
PPTX
AWS: Messaging Services in AWS Presentation
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
PPTX
Managing State & HTTP Requests In Ionic.
Angular Hydration Presentation (FrontEnd)
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Self-Healing Test Automation Framework - Healenium
Kanban Metrics Presentation (Project Management)
Java 17 features and implementation.pptx
Chaos Mesh Introducing Chaos in Kubernetes
GraalVM - A Step Ahead of JVM Presentation
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
DAPR - Distributed Application Runtime Presentation
Introduction to Azure Virtual WAN Presentation
Introduction to Argo Rollouts Presentation
Intro to Azure Container App Presentation
Insights Unveiled Test Reporting and Observability Excellence
Introduction to Splunk Presentation (DevOps)
Code Camp - Data Profiling and Quality Analysis Framework
AWS: Messaging Services in AWS Presentation
Amazon Cognito: A Primer on Authentication and Authorization
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Managing State & HTTP Requests In Ionic.

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
KodekX | Application Modernization Development
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Understanding_Digital_Forensics_Presentation.pptx
Spectroscopy.pptx food analysis technology
Review of recent advances in non-invasive hemoglobin estimation
Network Security Unit 5.pdf for BCA BBA.
sap open course for s4hana steps from ECC to s4
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Spectral efficient network and resource selection model in 5G networks
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
MIND Revenue Release Quarter 2 2025 Press Release
NewMind AI Weekly Chronicles - August'25 Week I
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
KodekX | Application Modernization Development
Dropbox Q2 2025 Financial Results & Investor Presentation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
cuic standard and advanced reporting.pdf
Programs and apps: productivity, graphics, security and other tools

Observables in Angular

  • 1. Presented By: Kiran & Aanchal Observables in Angular
  • 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes Punctuality Join the session 5 minutes prior to the session start time. We start on time and conclude on time! Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call. Avoid Disturbance Avoid unwanted chit chat during the session.
  • 3. Our Agenda 01 Introduction to Observables 02 Defining Observers 03 Subscribing and Unsubscribing 04 Rxjs 05 Some Rxjs operators
  • 4. Why do we need Observables? ● Angular makes use of observables as an interface to handle a variety of common asynchronous operations. ● Observables provide support for passing messages between parts of your application. ● The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of state changes. ● For example: The HTTP module uses observables to handle AJAX requests and responses.
  • 5. What are Observables? ● Observable in Angular is a feature that provides support for delivering messages between different parts of your single-page application. ● This feature is frequently used in Angular because it is responsible for handling multiple values, asynchronous programming in Javascript, and also event handling processes. ● Observables is a new primitive type which acts as a blueprint for how we want to create streams, subscribe to them, react to new values, and combine streams together to build new ones. ● Observables are declarative —that is, you define a function for publishing values, but it is not executed until a consumer subscribes to it. The subscribed consumer then receives notifications until the function completes, or until they unsubscribe.
  • 7. Promise vs Observables ● Emitting Values: An Observable can emit multiple values. On the other hand, Promises emit only a single value. ● Cancelable Subscriptions in Observable: We have a subscription that can be canceled in Observables but Promises cannot be canceled. The subscription allows us to stop the listener from receiving more values. ● Lazy & Eager: Observables are considered as lazy as they are not executed until we subscribe to them and Promises are not lazy because they execute after the creation. We need not subscribe to promises. Promises are executed eagerly while Observables are executed lazily.
  • 8. Observer & Observables ● Observers allow you to "push" new data into an observable sequence whereas An Observable is what we can use to listen, to new changes that are emitted by an Observer. ● Real-time usage of Observable and Observer - While receiving response from AJAX - While performing large tasks in client(browser)
  • 10. Creating Observers ● In order to show how subscribing works, we need to create a new observable. There is a constructor that you use to create new instances, but for illustration, we can use some methods from the RxJS library that create simple observables of frequently used types:
  • 11. Execution of Observables ● Next: The observer sends a value, which might be a number, string, or object, with each consecutive value. ● Error: If an error occurs in the Observable, no additional data may be sent to the Observable. ● Complete: The observer does not send any value, therefore the value is complete. This often indicates that the subscription to a certain Observable has been completed. ● Destroying an Observable: It simply means unsubscribing from it and removing it from the DOM.
  • 12. What is RxJs? ● RxJS (Reactive Extensions for JavaScript) is a library for reactive programming using observables that makes it easier to compose asynchronous or callback-based code. ● The library also provides utility functions for creating and working with observables. These utility functions can be used for: ➢ Converting existing code for async operations into observables ➢ Iterating through the values in a stream ➢ Mapping values to different types ➢ Filtering streams ➢ Composing multiple streams
  • 13. …RxJs When to use RxJS? If your project consists of lots of async task handling than RxJS is a good choice. Advantages of using RxJS ● RxJS can be used with other Javascript libraries and frameworks. ● RxJS is an awesome library when it comes to the handling of async tasks. ● RxJS offers a huge collection of operators in mathematical, transformation, filtering, error handling, join categories that makes life easy when used with reactive programming. Disadvantages of using RxJS ● Debugging the code with observables is little difficult.
  • 14. RxJs Operators ● map - map operator is a transformation operator used to transform the items emitted by an Observable by applying a function to each item. ● take - emits only the first count values emitted by the source Observable ● takeWhile - passes values from the source observable to the observer as long as the function known as the predicate returns true. ● skip - it allows you to ignore the first x emissions from the source ● filter - filter items emitted by the source Observable by only emitting those that satisfy a specified predicate.
  • 15. What is Memory Leak? ● A memory leak is a type of resource leak caused by poor management of memory allocation in a way that is not cleared from the memory when is not needed anymore. ● The memory leak is one of the worst problems developers could have since it is very difficult to debug and catch. ● This would lead to slow performance or even a crashing application. ● Most often memory leaks are caused due to bad management of Observables. ● There are certain ways to avoid it. You can use Angular async pipe or you can unsubscribe properly from observable.
  • 16. DEMO
  • 17. References ● https://angular.io/guide/observables ● https://www.learnrxjs.io/learn-rxjs/operators ● https://www.tektutorialshub.com/angular/rxjs-observable-using-create-of-from-i n-angular/ ● https://luukgruijs.medium.com/understanding-creating-and-subscribing-to-obse rvables-in-angular-426dbf0b04a3 ● https://www.tutorialspoint.com/rxjs/rxjs_overview.htm
  • 18. Thank You ! Get in touch with us: Lorem Studio, Lord Building D4456, LA, USA