SlideShare a Scribd company logo
Angular is on Fire(base)!
Shmuela Jacobs
AMSTERDAM 16 - 17 MAY 2017
Shmuela Jacobs
Front-end Developer, Consultant & Trainer
shmuela@ng-girls.org
shmool
@ShmuelaJ
Shmuela Jacobs
Front-end Developer & Consultant
shmuela@ng-girls.org
shmool
@ShmuelaJ
Shmuela Jacobs
Front-end Developer & Consultant
shmuela@ng-girls.org
shmool
@ShmuelaJ
Shmuela Jacobs
Front-end Developer & Consultant
shmuela@ng-girls.org
shmool
@ShmuelaJ
https://openfire-cookbook.firebaseapp.com
Demo App - OpenFire Cookbook
Firebase
4
https://github.com/angular/angular-cli
Angular CLI
https://github.com/angular/angularfire2
AngularFire2
Do stuff like:
<div> {{ (authService.authState$ | async )?.displayName }} </div>
Firebase Authentication
Email + Password - with all the needed features
Federated identity providers - Google, Facebook...
Other identity providers - using Cloud Functions
Smart user management
Anonymous user
DB with AngularFire2
Real time
Read/write protection
Lists
Objects
Queries - observables!
Cloud Functions
Firebase cloud messaging (FCM)
send emails
send SMS
modify realtime DB
execute intensive tasks
access storage
batch jobs
integrate with 3rd party services and APIs
NEW!
Cloud Functions Triggers
Realtime DB - on write
Authentication - user created/deleted
Cloud Storage
Analytics
HTTP
Google Cloud Pub/Sub (messaging)
Project Setup
npm i angular-cli -g
ng new my-app --style=scss --prefix=sj -it --routing
cd my-app
npm i firebase angularfire2 -S
npm i firebase-tools -g
firebase login
firebase init
OpenFire CookBook
Authentication
Real Time Database
Cloud Functions
NEW!
OpenFire Cookbook User Management
Authentication - password + Google
Routing
User Avatar
Read permission - all
Write permission - authenticated user
Edit permission - recipe owner
DB Rules
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
DB Rules
{
"rules": {
".read": true,
".write": true
}
}
DB Rules
{

"rules": {

".read": true,

".write": false,

"recipes": {

"$recipeId": {

".write": "auth.uid != null && (!data.exists()
|| data.child('uid').val() === auth.uid)"

}

}

}

}
DB Rules
{
"rules": {
// By default, make all data private unless specified otherwise.
".read": false,
".write": false,
"room-metadata": {
".read": true,
"$roomId": {
// Append-only by anyone, and admins can add official rooms, and edit or remove rooms as
well.
".write": "(auth != null) && (!data.exists() || root.child('moderators').hasChild(auth.uid)
|| data.child('createdByUserId').val() === auth.uid)",
".validate": "newData.hasChildren(['name','type'])",
"id": {
".validate": "(newData.val() === $roomId)"
},
"createdByUserId": {
".validate": "(auth.uid === newData.val())"
},
"numUsers": {
".validate": "(newData.isNumber())"
},
"type": {
".validate": "('public' === newData.val()) || 'private' === newData.val() || ('official'
Erik Haddad - firechat
https://firechat.social
erikhaddad
Deploy
ng build --prod
firebase deploy
More in Firebase
Storage
Notifications
Invites
AdWords
Analytics
...and more!
firebase.google.com
angular.io
github.com/angular/angularfire2
angularfirebase.com
Shmuela Jacobs
shmuela@ng-girls.org
shmool
@ShmuelaJ
ng-girls.org

More Related Content

Angular is on Fire(base) - Shmuela Jacobs - Codemotion Amsterdam 2017