SlideShare a Scribd company logo
www.webstackacademy.com
Firebase Integration
Angular
www.webstackacademy.comwww.webstackacademy.com
Connecting the dots
(A Quick looking-back!)
www.webstackacademy.com
What we have done so far?
Components Services Directives
Backend
integration
Component creation
Binding (Data & Event)
Dependency injection
HTTP dummy-endpoint
DOM manipulation
Structural, Attribute and
customized
We are HERE!
www.webstackacademy.com
What we have done so far? – Static / Compiled data
• When we access any data in the business logic, local variables are used within the class so far
(ex: courses = ["Fullstack", "Frontend", "Backend", "Java"]). This information is obtained in the
view in form of interpolation {{ course }} mechanism
• We also understood how to use event (Using () mechanism), data (Using [] mechanism)
and two way binding - "Banana in a Box" (Using [()] mechanism)
• Any time we wanted to demonstrate change in the data, we have edited the code changed
some items and re-launched the angular application (using ng serve --open)
• However in real time application data will be fetched dynamically from an external source (ex:
Firebase or your own custom backend application) which will not only ensure we get rid of using
static local variables but also the data takes care of Asynchronous updates
• Primarily data updates include Create, Read, Update and Delete which is popularly known as
CRUD operations
www.webstackacademy.comwww.webstackacademy.com
Introduction to Backend
(First level understanding)
www.webstackacademy.com
Frontend and Backend
www.webstackacademy.com
Frontend vs. Backend - Differences
Frontend Backend
• Primarily a web client (HTTP) or a mobile app
• Deals with user interface (HTML + CSS) and
interactivity (JS or TS)
• Obtains data (ex: Input box) or event (ex: Form
submission followed by submit)
• Doesn't have any storage capacity or business
logic to handle data
• Primarily a web server supported by a Database
(ex: MongoDB)
• Deals with incoming requests from HTTP clients
from various sources
• Applies business logic on the input and provides
appropriate response (ex: Forms)
• Deals with non-functional items like security,
scalability, performance. Multiple options of
languages available (ex: Java, Python, JavaScript,
Ruby etc..)
• Both client and server follow standard HTTP protocol is followed over TCP/IP network
• A brief discussion about OSI and TCP/IP
www.webstackacademy.com
Relational vs Non-relational DB
Relational DB Non-relational DB
• Data structure that allows you to link
information from different 'tables' or different
types of data buckets.
• A data bucket must contain what is called a key
or index (that allows to uniquely identify any
atomic chunk of data within the bucket).
• Other data buckets may refer to that key so as
to create a link between their data atoms and
the atom pointed to by the key.
• Just stores data in forms of "documents" (JSON
format) doesn’t place any constraints like table.
Its called “unstructured” database
• Data structure that allows to store information in
different forms - Trees, Graphs thereby giving
more flexibility in terms of storage
• Other data buckets cannot refer to a particular
table with the key. Data is very much local to an
application.
www.webstackacademy.comwww.webstackacademy.com
Introduction to Firebase
(Backend integration platform)
www.webstackacademy.com
Introduction to Firebase
 Firebase is a cloud based mobile and web app development platform provided by Google
 It offers developers with tools, databases, services etc.. to build any web or mobile application without
bothering much into the backend web development
 The Firebase Database is a cloud-hosted, non-relational DB database (Mongo DB) that lets you store and
sync between your users in real-time.
 It offers good amount of features for free (to develop and launch your app) and then moves
onto paid model
 Advanced features (ex: Analytics) are provided to monetize your application better
www.webstackacademy.com
Firebase – Our Goals
 Integrate a frontend application developed using Angular framework with Firebase and build end-to-
end perspective
 Practically understand real-time use-cases of core angular features (components, services, directives,
forms etc..) by dealing with real-time data
 Enhance "grey-box" knowledge of frontend (Angular) with "black-box" knowledge of backend (Firebase)
 Obtain introductory knowledge about backend, which will further get enhanced with backend
programming topics (ex: Node.js & Express.js)
www.webstackacademy.comwww.webstackacademy.com
Firebase Integration – Part I
(Configuring Firebase Server)
www.webstackacademy.com
Goto http://firebase.google.com and login with your Gmail / Google credentials
1. Login and Access your console
www.webstackacademy.com
Click on the option and create your own project
2. Create your project
www.webstackacademy.com
• Enter project name
• Enter country
• Accept terms & conditions
• Create project
3. Enter Basic information for your project
www.webstackacademy.com
Navigate to your project dashboard. Ensure you are choosing the right project.
4. Goto your project dashboard
www.webstackacademy.com
Click “Add Firebase to your Web App” it
will open a project integration settings
as follows. Copy the items inside
“config” section and keep them handy.
5. Copy your project integration settings
www.webstackacademy.com
Goto project “Database” and select FireStore (Beta) option
6. Choose your Database
www.webstackacademy.com
Add meaningful data in collection, document and field columns and create your DB
7. Enter your data
www.webstackacademy.comwww.webstackacademy.com
Firebase Integration – Part II
(Configuring Firebase Client - Angular)
www.webstackacademy.com
1. Installing Firebase packages
$ npm install firebase angularfire2 --save
• In order to integrate Firebase with your Angular application two packages need to be
installed.
 Firebase: Firebase library for web and Node.js (Server)
 Angularfire2: Firebase library for Angular (Client)
• To install them execute the following commands (from your project folder)
• By using the --save option enters the packages into your environment.
• Check your package.json file to ensure these packages are listed in the dependency
www.webstackacademy.com
1. Installing Firebase packages
Check package.json settings to ensure packages are properly imported into the project
www.webstackacademy.com
2. Copy your Firebase project integration settings
Goto environment.ts file and copy Firebase settings (which you copied earlier)
export const environment = {
production: false,
firebase : {
apiKey: "AIzaSyCbCrluicS3ls1ER3NWcmi0CJJjVQ5aeBQ",
authDomain: "webstack-academy.firebaseapp.com",
databaseURL: "https://webstack-academy.firebaseio.com",
projectId: "webstack-academy",
storageBucket: "webstack-academy.appspot.com",
messagingSenderId: "247936282085"
}
};
www.webstackacademy.com
3. Changes in Modules file
Make the Angular and related import paths
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AngularFireModule } from 'angularfire2';
import { AngularFirestoreModule } from 'angularfire2/firestore';
import { AppComponent } from './app.component';
import { environment } from '../environments/environment';
www.webstackacademy.com
3. Changes in Modules file
Add them into import section as well
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
AngularFireModule.initializeApp(environment.firebase,'angularfs'),
AngularFirestoreModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
www.webstackacademy.com
4. Changes in Component files
Component Imports and constructor
import { AngularFirestore } from 'angularfire2/firestore';
import { Observable } from 'rxjs';
// Observable and other function details in next section
items: Observable<Item[]>;
constructor(public db: AngularFirestore) {
this.items = this.db.collection('courses').valueChanges();
this.items.subscribe(items => {
console.log(items);
});
}
www.webstackacademy.com
5. Changes in view file
Using Directives display the items fetched from Firebase in the View file. When you
change values in the Firebase it should reflect in the view dynamically
<h1> Angular integration with Firebase </h1>
<ul>
<li *ngFor="let item of items | async">
{{ item.coursename }} --> {{item.duration}}
</li>
</ul>
www.webstackacademy.comwww.webstackacademy.com
Performing CRUD operations
(CRUD Foundational Concepts)
www.webstackacademy.com
CRUD Operations
 In real-time use cases front end will interact with a database to perform Create, Read, Update and
Delete (popularly referred as CRUD) operations.
 For example, you have used Firebase to retrieve course list from the DB, which is nothing but a Read
operation. However if you want to add new courses (ex: Data Science Course) into the list, modify
existing course properties (ex: Duration) or delete existing course you need to know other operations.
 Also while dealing with remote databases (like Firebase) CRUD operations will not happen in real-time.
 There would be some delays (ex: Due to Network traffic), so the client applications like Angular need to
handle them in an Asynchronous manner
 Angular provides a mechanism called Observables, using which Asynchronous handling is done
www.webstackacademy.com
CRUD Operations – Foundational Concepts
 Synchronous vs Asynchronous handling
 Call-back functions
 Observables
 Reactive programming
www.webstackacademy.com
Synchronous vs Asynchronous Programming
 The definition of Synchronous and Asynchronous is very broad, in our context it can be defined as
follows:
 Synchronous means that the caller waits for the response for completion
 Asynchronous that the caller continues and a response comes later (if applicable)
 Synchronous is easier to handle but it consumes higher amount of resources
 Asynchronous requires sophisticated mechanism (ex: Call-backs) but it consumes lesser amount of
resource
 In modern day development, Asynchronous mechanisms are highly preferred
 Observables in Angular is practically implementing Asynchronous programming
www.webstackacademy.com
Discount Purchase - Example – Synchronous way
www.webstackacademy.com
Discount Purchase - Example – Asynchronous way
www.webstackacademy.com
Observables in Angular
• Observables provide support for passing messages between publishers and subscribers in your
application (also known as “pub-sub” model).
• Interested Angular component can subscribe for a particular event (in our case it is Firebase DB
handling) and Observarable will notify once the event occurs (ex: Database read) via call-back
• Observables offer significant benefits over other techniques for event handling, asynchronous
programming, and handling multiple values. An observable can deliver multiple values of any
type—literals, messages, or events, depending on the context.
• Because setup and teardown logic are both handled by the observable, your application code
only needs to worry about subscribing to consume values, and when done, unsubscribing.
• Observables are used in variety of use-cases (HTTP response / Interval timer) apart from
Firebase. Because of these advantages, observables are used extensively within Angular, and are
recommended for app development as well.
www.webstackacademy.com
Reactive Programming
• Reactive programming is an asynchronous programming paradigm concerned with data streams
and the propagation of change.
• RxJS (Reactive Extensions for JavaScript) is a library for reactive programming using observables
that makes it easier to compose asynchronous or call-back based code (RxJS Docs).
• RxJS provides an implementation of the Observable type, which is needed until the type
becomes part of the language and until browsers support it.
• 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
www.webstackacademy.com
The subscribe() Method – A closer look!
• A handler for receiving observable notifications implements the Observer interface. It is an object
that defines call-back methods to handle the three types of notifications that an observable can
send:
 Next:
 Required. A handler for each delivered value.
 Called zero or more times after execution starts.
 Error:
 Optional. A handler for an error notification.
 An error halts execution of the observable instance.
 Complete:
 Optional. A handler for the execution-complete notification.
• The above mentioned functionality is implemented via the subscribe() function
• The type of data returned and handling mechanism is purely based on the use-case
www.webstackacademy.com
The subscribe() Method – A closer look!
myObservable = ..... // Async method
myObservable.subscribe(
x => console.log('Observer got a next value: ' + x),
err => console.log('Observer got an error: ' + err),
() => console.log('Observer got a complete notification')
);
www.webstackacademy.com
And Finally….to back to our same source code….
import { AngularFirestore } from 'angularfire2/firestore';
import { Observable } from 'rxjs';
items: Observable<Item[]>;
constructor(public db: AngularFirestore) {
// Monitor changes
this.items = this.db.collection('courses').valueChanges();
// Asynchronously retrieve changed values
this.items.subscribe(myValues => {
console.log(myValues);
});
}
www.webstackacademy.comwww.webstackacademy.com
CRUD APIs
(Various APIs supported in Angular for Firebase)
www.webstackacademy.com
Data organization in Firebase
• In Firebase DB, data is organized at three levels – Collection, Document and Field
• There are various APIs available to setup, access and perform CRUD operations in Angular. Details
are available in official GIT links provided below.
• Installation and Setup:
 https://github.com/angular/angularfire2/blob/HEAD/docs/install-and-setup.md
• Handling Documents:
 https://github.com/angular/angularfire2/blob/b2d44a8536de1e8a38152e8c60fef250af2e21a9/docs/firestore
/documents.md
• Handling Collections:
 https://github.com/angular/angularfire2/blob/b2d44a8536de1e8a38152e8c60fef250af2e21a9/docs/f
irestore/collections.md
www.webstackacademy.com
Exercise
• Implement the “to-do” list for the user with the following functionality:
 Enter to-do item, category and priority (ex: “Learn TypeScript” , “Skill”, “High”)
 Integrate the user entered data with the Firebase backend
 Provide buttons to perform the following operations:
 Add
 Modify
 Delete
 Implement a service to handle the Firebase endpoint functionality
 Use Interfaces and export them for common usage
 Display task items based on category
www.webstackacademy.com
WebStack Academy
#83, Farah Towers,
1st Floor, MG Road,
Bangalore – 560001
M: +91-809 555 7332
E: training@webstackacademy.com
WSA in Social Media:

More Related Content

What's hot

SQL - RDBMS Concepts
SQL - RDBMS ConceptsSQL - RDBMS Concepts
SQL - RDBMS Concepts
WebStackAcademy
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
Smithss25
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
John Coggeshall
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
Vibrant Technologies & Computers
 
Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax here
jarnail
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
Nir Elbaz
 
Ajax
AjaxAjax
Jquery Ajax
Jquery AjaxJquery Ajax
Jquery Ajax
Anand Kumar Rajana
 
Jsp & Ajax
Jsp & AjaxJsp & Ajax
Jsp & Ajax
Ang Chen
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part II
Eugene Lazutkin
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
Naveen Sihag
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
Venkat Pinagadi
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applications
Eugene Lazutkin
 
AJAX
AJAXAJAX
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
Adnan Sohail
 
Ajax
AjaxAjax
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
ukdpe
 
mobile in the cloud with diamonds. improved.
mobile in the cloud with diamonds. improved.mobile in the cloud with diamonds. improved.
mobile in the cloud with diamonds. improved.
Oleg Shanyuk
 
Ajax
AjaxAjax
Ajax
AjaxAjax

What's hot (20)

SQL - RDBMS Concepts
SQL - RDBMS ConceptsSQL - RDBMS Concepts
SQL - RDBMS Concepts
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax here
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Ajax
AjaxAjax
Ajax
 
Jquery Ajax
Jquery AjaxJquery Ajax
Jquery Ajax
 
Jsp & Ajax
Jsp & AjaxJsp & Ajax
Jsp & Ajax
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part II
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applications
 
AJAX
AJAXAJAX
AJAX
 
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
 
Ajax
AjaxAjax
Ajax
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
 
mobile in the cloud with diamonds. improved.
mobile in the cloud with diamonds. improved.mobile in the cloud with diamonds. improved.
mobile in the cloud with diamonds. improved.
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 

Similar to Angular - Chapter 6 - Firebase Integration

MongoDB Evenings DC: Get MEAN and Lean with Docker and Kubernetes
MongoDB Evenings DC: Get MEAN and Lean with Docker and KubernetesMongoDB Evenings DC: Get MEAN and Lean with Docker and Kubernetes
MongoDB Evenings DC: Get MEAN and Lean with Docker and Kubernetes
MongoDB
 
Contentful with Netgen Layouts workshop
Contentful with Netgen Layouts workshopContentful with Netgen Layouts workshop
Contentful with Netgen Layouts workshop
Ivo Lukac
 
CouchDB
CouchDBCouchDB
CouchDB
Jacob Diamond
 
Introduction to meteor
Introduction to meteorIntroduction to meteor
Introduction to meteor
NodeXperts
 
Academy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageAcademy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storage
Binary Studio
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
Gary Pedretti
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
Rob Davarnia
 
Angular js firebase-preso
Angular js firebase-presoAngular js firebase-preso
Angular js firebase-preso
Avinash Kondagunta
 
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
Jim McKeeth
 
NodeJS @ ACS
NodeJS @ ACSNodeJS @ ACS
NodeJS @ ACS
Mauro Parra-Miranda
 
Adopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuiteAdopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuite
AnswerModules
 
Approaches to mobile site development
Approaches to mobile site developmentApproaches to mobile site development
Approaches to mobile site development
Erik Mitchell
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
Igor Talevski
 
Firebase - cloud based real time database
Firebase - cloud based real time databaseFirebase - cloud based real time database
Firebase - cloud based real time database
Glenn Bech
 
Nasdanika Foundation Server
Nasdanika Foundation ServerNasdanika Foundation Server
Nasdanika Foundation Server
Pavel Vlasov
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4
Jon Galloway
 
Faites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchFaites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB Stitch
MongoDB
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
Muthuselvam RS
 
ASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesASP .Net Core SPA Templates
ASP .Net Core SPA Templates
Eamonn Boyle
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
Rasel Khan
 

Similar to Angular - Chapter 6 - Firebase Integration (20)

MongoDB Evenings DC: Get MEAN and Lean with Docker and Kubernetes
MongoDB Evenings DC: Get MEAN and Lean with Docker and KubernetesMongoDB Evenings DC: Get MEAN and Lean with Docker and Kubernetes
MongoDB Evenings DC: Get MEAN and Lean with Docker and Kubernetes
 
Contentful with Netgen Layouts workshop
Contentful with Netgen Layouts workshopContentful with Netgen Layouts workshop
Contentful with Netgen Layouts workshop
 
CouchDB
CouchDBCouchDB
CouchDB
 
Introduction to meteor
Introduction to meteorIntroduction to meteor
Introduction to meteor
 
Academy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageAcademy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storage
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
Angular js firebase-preso
Angular js firebase-presoAngular js firebase-preso
Angular js firebase-preso
 
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
 
NodeJS @ ACS
NodeJS @ ACSNodeJS @ ACS
NodeJS @ ACS
 
Adopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuiteAdopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuite
 
Approaches to mobile site development
Approaches to mobile site developmentApproaches to mobile site development
Approaches to mobile site development
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
 
Firebase - cloud based real time database
Firebase - cloud based real time databaseFirebase - cloud based real time database
Firebase - cloud based real time database
 
Nasdanika Foundation Server
Nasdanika Foundation ServerNasdanika Foundation Server
Nasdanika Foundation Server
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4
 
Faites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchFaites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB Stitch
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
ASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesASP .Net Core SPA Templates
ASP .Net Core SPA Templates
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 

More from WebStackAcademy

Webstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement JourneyWebstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement Journey
WebStackAcademy
 
WSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per SecondWSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per Second
WebStackAcademy
 
WSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer CourseWSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer Course
WebStackAcademy
 
Career Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
WebStackAcademy
 
Webstack Academy - Internship Kick Off
Webstack Academy - Internship Kick OffWebstack Academy - Internship Kick Off
Webstack Academy - Internship Kick Off
WebStackAcademy
 
Building Your Online Portfolio
Building Your Online PortfolioBuilding Your Online Portfolio
Building Your Online Portfolio
WebStackAcademy
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
WebStackAcademy
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
WebStackAcademy
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
WebStackAcademy
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
WebStackAcademy
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
WebStackAcademy
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
WebStackAcademy
 
JavaScript - Chapter 3 - Introduction
 JavaScript - Chapter 3 - Introduction JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 3 - Introduction
WebStackAcademy
 

More from WebStackAcademy (20)

Webstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement JourneyWebstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement Journey
 
WSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per SecondWSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per Second
 
WSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer CourseWSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer Course
 
Career Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
 
Webstack Academy - Internship Kick Off
Webstack Academy - Internship Kick OffWebstack Academy - Internship Kick Off
Webstack Academy - Internship Kick Off
 
Building Your Online Portfolio
Building Your Online PortfolioBuilding Your Online Portfolio
Building Your Online Portfolio
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
 
JavaScript - Chapter 3 - Introduction
 JavaScript - Chapter 3 - Introduction JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 3 - Introduction
 

Recently uploaded

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 

Recently uploaded (20)

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 

Angular - Chapter 6 - Firebase Integration

  • 3. www.webstackacademy.com What we have done so far? Components Services Directives Backend integration Component creation Binding (Data & Event) Dependency injection HTTP dummy-endpoint DOM manipulation Structural, Attribute and customized We are HERE!
  • 4. www.webstackacademy.com What we have done so far? – Static / Compiled data • When we access any data in the business logic, local variables are used within the class so far (ex: courses = ["Fullstack", "Frontend", "Backend", "Java"]). This information is obtained in the view in form of interpolation {{ course }} mechanism • We also understood how to use event (Using () mechanism), data (Using [] mechanism) and two way binding - "Banana in a Box" (Using [()] mechanism) • Any time we wanted to demonstrate change in the data, we have edited the code changed some items and re-launched the angular application (using ng serve --open) • However in real time application data will be fetched dynamically from an external source (ex: Firebase or your own custom backend application) which will not only ensure we get rid of using static local variables but also the data takes care of Asynchronous updates • Primarily data updates include Create, Read, Update and Delete which is popularly known as CRUD operations
  • 7. www.webstackacademy.com Frontend vs. Backend - Differences Frontend Backend • Primarily a web client (HTTP) or a mobile app • Deals with user interface (HTML + CSS) and interactivity (JS or TS) • Obtains data (ex: Input box) or event (ex: Form submission followed by submit) • Doesn't have any storage capacity or business logic to handle data • Primarily a web server supported by a Database (ex: MongoDB) • Deals with incoming requests from HTTP clients from various sources • Applies business logic on the input and provides appropriate response (ex: Forms) • Deals with non-functional items like security, scalability, performance. Multiple options of languages available (ex: Java, Python, JavaScript, Ruby etc..) • Both client and server follow standard HTTP protocol is followed over TCP/IP network • A brief discussion about OSI and TCP/IP
  • 8. www.webstackacademy.com Relational vs Non-relational DB Relational DB Non-relational DB • Data structure that allows you to link information from different 'tables' or different types of data buckets. • A data bucket must contain what is called a key or index (that allows to uniquely identify any atomic chunk of data within the bucket). • Other data buckets may refer to that key so as to create a link between their data atoms and the atom pointed to by the key. • Just stores data in forms of "documents" (JSON format) doesn’t place any constraints like table. Its called “unstructured” database • Data structure that allows to store information in different forms - Trees, Graphs thereby giving more flexibility in terms of storage • Other data buckets cannot refer to a particular table with the key. Data is very much local to an application.
  • 10. www.webstackacademy.com Introduction to Firebase  Firebase is a cloud based mobile and web app development platform provided by Google  It offers developers with tools, databases, services etc.. to build any web or mobile application without bothering much into the backend web development  The Firebase Database is a cloud-hosted, non-relational DB database (Mongo DB) that lets you store and sync between your users in real-time.  It offers good amount of features for free (to develop and launch your app) and then moves onto paid model  Advanced features (ex: Analytics) are provided to monetize your application better
  • 11. www.webstackacademy.com Firebase – Our Goals  Integrate a frontend application developed using Angular framework with Firebase and build end-to- end perspective  Practically understand real-time use-cases of core angular features (components, services, directives, forms etc..) by dealing with real-time data  Enhance "grey-box" knowledge of frontend (Angular) with "black-box" knowledge of backend (Firebase)  Obtain introductory knowledge about backend, which will further get enhanced with backend programming topics (ex: Node.js & Express.js)
  • 13. www.webstackacademy.com Goto http://firebase.google.com and login with your Gmail / Google credentials 1. Login and Access your console
  • 14. www.webstackacademy.com Click on the option and create your own project 2. Create your project
  • 15. www.webstackacademy.com • Enter project name • Enter country • Accept terms & conditions • Create project 3. Enter Basic information for your project
  • 16. www.webstackacademy.com Navigate to your project dashboard. Ensure you are choosing the right project. 4. Goto your project dashboard
  • 17. www.webstackacademy.com Click “Add Firebase to your Web App” it will open a project integration settings as follows. Copy the items inside “config” section and keep them handy. 5. Copy your project integration settings
  • 18. www.webstackacademy.com Goto project “Database” and select FireStore (Beta) option 6. Choose your Database
  • 19. www.webstackacademy.com Add meaningful data in collection, document and field columns and create your DB 7. Enter your data
  • 20. www.webstackacademy.comwww.webstackacademy.com Firebase Integration – Part II (Configuring Firebase Client - Angular)
  • 21. www.webstackacademy.com 1. Installing Firebase packages $ npm install firebase angularfire2 --save • In order to integrate Firebase with your Angular application two packages need to be installed.  Firebase: Firebase library for web and Node.js (Server)  Angularfire2: Firebase library for Angular (Client) • To install them execute the following commands (from your project folder) • By using the --save option enters the packages into your environment. • Check your package.json file to ensure these packages are listed in the dependency
  • 22. www.webstackacademy.com 1. Installing Firebase packages Check package.json settings to ensure packages are properly imported into the project
  • 23. www.webstackacademy.com 2. Copy your Firebase project integration settings Goto environment.ts file and copy Firebase settings (which you copied earlier) export const environment = { production: false, firebase : { apiKey: "AIzaSyCbCrluicS3ls1ER3NWcmi0CJJjVQ5aeBQ", authDomain: "webstack-academy.firebaseapp.com", databaseURL: "https://webstack-academy.firebaseio.com", projectId: "webstack-academy", storageBucket: "webstack-academy.appspot.com", messagingSenderId: "247936282085" } };
  • 24. www.webstackacademy.com 3. Changes in Modules file Make the Angular and related import paths import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AngularFireModule } from 'angularfire2'; import { AngularFirestoreModule } from 'angularfire2/firestore'; import { AppComponent } from './app.component'; import { environment } from '../environments/environment';
  • 25. www.webstackacademy.com 3. Changes in Modules file Add them into import section as well @NgModule({ declarations: [ AppComponent, ], imports: [ BrowserModule, AngularFireModule.initializeApp(environment.firebase,'angularfs'), AngularFirestoreModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
  • 26. www.webstackacademy.com 4. Changes in Component files Component Imports and constructor import { AngularFirestore } from 'angularfire2/firestore'; import { Observable } from 'rxjs'; // Observable and other function details in next section items: Observable<Item[]>; constructor(public db: AngularFirestore) { this.items = this.db.collection('courses').valueChanges(); this.items.subscribe(items => { console.log(items); }); }
  • 27. www.webstackacademy.com 5. Changes in view file Using Directives display the items fetched from Firebase in the View file. When you change values in the Firebase it should reflect in the view dynamically <h1> Angular integration with Firebase </h1> <ul> <li *ngFor="let item of items | async"> {{ item.coursename }} --> {{item.duration}} </li> </ul>
  • 29. www.webstackacademy.com CRUD Operations  In real-time use cases front end will interact with a database to perform Create, Read, Update and Delete (popularly referred as CRUD) operations.  For example, you have used Firebase to retrieve course list from the DB, which is nothing but a Read operation. However if you want to add new courses (ex: Data Science Course) into the list, modify existing course properties (ex: Duration) or delete existing course you need to know other operations.  Also while dealing with remote databases (like Firebase) CRUD operations will not happen in real-time.  There would be some delays (ex: Due to Network traffic), so the client applications like Angular need to handle them in an Asynchronous manner  Angular provides a mechanism called Observables, using which Asynchronous handling is done
  • 30. www.webstackacademy.com CRUD Operations – Foundational Concepts  Synchronous vs Asynchronous handling  Call-back functions  Observables  Reactive programming
  • 31. www.webstackacademy.com Synchronous vs Asynchronous Programming  The definition of Synchronous and Asynchronous is very broad, in our context it can be defined as follows:  Synchronous means that the caller waits for the response for completion  Asynchronous that the caller continues and a response comes later (if applicable)  Synchronous is easier to handle but it consumes higher amount of resources  Asynchronous requires sophisticated mechanism (ex: Call-backs) but it consumes lesser amount of resource  In modern day development, Asynchronous mechanisms are highly preferred  Observables in Angular is practically implementing Asynchronous programming
  • 32. www.webstackacademy.com Discount Purchase - Example – Synchronous way
  • 33. www.webstackacademy.com Discount Purchase - Example – Asynchronous way
  • 34. www.webstackacademy.com Observables in Angular • Observables provide support for passing messages between publishers and subscribers in your application (also known as “pub-sub” model). • Interested Angular component can subscribe for a particular event (in our case it is Firebase DB handling) and Observarable will notify once the event occurs (ex: Database read) via call-back • Observables offer significant benefits over other techniques for event handling, asynchronous programming, and handling multiple values. An observable can deliver multiple values of any type—literals, messages, or events, depending on the context. • Because setup and teardown logic are both handled by the observable, your application code only needs to worry about subscribing to consume values, and when done, unsubscribing. • Observables are used in variety of use-cases (HTTP response / Interval timer) apart from Firebase. Because of these advantages, observables are used extensively within Angular, and are recommended for app development as well.
  • 35. www.webstackacademy.com Reactive Programming • Reactive programming is an asynchronous programming paradigm concerned with data streams and the propagation of change. • RxJS (Reactive Extensions for JavaScript) is a library for reactive programming using observables that makes it easier to compose asynchronous or call-back based code (RxJS Docs). • RxJS provides an implementation of the Observable type, which is needed until the type becomes part of the language and until browsers support it. • 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
  • 36. www.webstackacademy.com The subscribe() Method – A closer look! • A handler for receiving observable notifications implements the Observer interface. It is an object that defines call-back methods to handle the three types of notifications that an observable can send:  Next:  Required. A handler for each delivered value.  Called zero or more times after execution starts.  Error:  Optional. A handler for an error notification.  An error halts execution of the observable instance.  Complete:  Optional. A handler for the execution-complete notification. • The above mentioned functionality is implemented via the subscribe() function • The type of data returned and handling mechanism is purely based on the use-case
  • 37. www.webstackacademy.com The subscribe() Method – A closer look! myObservable = ..... // Async method myObservable.subscribe( x => console.log('Observer got a next value: ' + x), err => console.log('Observer got an error: ' + err), () => console.log('Observer got a complete notification') );
  • 38. www.webstackacademy.com And Finally….to back to our same source code…. import { AngularFirestore } from 'angularfire2/firestore'; import { Observable } from 'rxjs'; items: Observable<Item[]>; constructor(public db: AngularFirestore) { // Monitor changes this.items = this.db.collection('courses').valueChanges(); // Asynchronously retrieve changed values this.items.subscribe(myValues => { console.log(myValues); }); }
  • 40. www.webstackacademy.com Data organization in Firebase • In Firebase DB, data is organized at three levels – Collection, Document and Field • There are various APIs available to setup, access and perform CRUD operations in Angular. Details are available in official GIT links provided below. • Installation and Setup:  https://github.com/angular/angularfire2/blob/HEAD/docs/install-and-setup.md • Handling Documents:  https://github.com/angular/angularfire2/blob/b2d44a8536de1e8a38152e8c60fef250af2e21a9/docs/firestore /documents.md • Handling Collections:  https://github.com/angular/angularfire2/blob/b2d44a8536de1e8a38152e8c60fef250af2e21a9/docs/f irestore/collections.md
  • 41. www.webstackacademy.com Exercise • Implement the “to-do” list for the user with the following functionality:  Enter to-do item, category and priority (ex: “Learn TypeScript” , “Skill”, “High”)  Integrate the user entered data with the Firebase backend  Provide buttons to perform the following operations:  Add  Modify  Delete  Implement a service to handle the Firebase endpoint functionality  Use Interfaces and export them for common usage  Display task items based on category
  • 42. www.webstackacademy.com WebStack Academy #83, Farah Towers, 1st Floor, MG Road, Bangalore – 560001 M: +91-809 555 7332 E: training@webstackacademy.com WSA in Social Media: