Last active
August 15, 2017 10:36
-
-
Save angular-academy-devs/bc7e557ba3d8e87ee93ab037f84bc21d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {FirebaseApp} from "angularfire2"; | |
@Injectable() | |
export class LessonsService { | |
constructor( @Inject(FirebaseApp) fb) { | |
const rootDbRef = fb.database().ref(); | |
rootDebRef.on('value', snapshot => console.log(snapshot.val())); | |
... | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NgModule({ | |
declarations: [ | |
AppComponent, | |
... | |
], | |
imports: [ | |
BrowserModule, | |
AngularFireModule.initializeApp(firebaseConfig), | |
AngularFireDatabaseModule, | |
AngularFireAuthModule, | |
RouterModule.forRoot(routerConfig) | |
], | |
providers: [...], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from '@angular/core'; | |
import {Observable, Subject} from "rxjs/Rx"; | |
import {Lesson} from "./lesson"; | |
import {AngularFireDatabase} from "angularfire2"; | |
@Injectable() | |
export class LessonsService { | |
constructor(private db:AngularFireDatabase) { | |
} | |
findAllLessons():Observable<Lesson[]> { | |
return this.db.list('lessons') | |
.do(console.log) | |
.map(Lesson.fromJsonList); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {firebaseConfig} from "./src/environments/firebase.config"; | |
import {initializeApp, auth,database} from 'firebase'; | |
initializeApp(firebaseConfig); | |
auth() | |
.signInWithEmailAndPassword('[email protected]', 'test123') | |
.then(onLoginSuccess) | |
.catch(onLoginError); | |
function onLoginSuccess() { | |
... | |
} | |
function onLoginError() { | |
... | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"-KT_udWMM0vKlnp-naE3": { | |
"courseListIcon": "https://angular-academy.s3.amazonaws.com/main-logo/main-page-logo-small-hat.png", | |
"description": "Angular 2 Tutorial For Beginners", | |
"iconUrl": "https://angular-academy.s3.amazonaws.com/thumbnails/angular2-for-beginners.jpg", | |
"longDescription": "Establish a solid layer of fundamentals, learn what's under the hood of Angular 2", | |
"url": "getting-started-with-angular2" | |
}, | |
"-KT_udWj0knDpxHaxcKv": { | |
"courseListIcon": "https://angular-academy.s3.amazonaws.com/course-logos/observables_rxjs.png", | |
"description": "Angular 2 HTTP and Services", | |
"iconUrl": "https://angular-academy.s3.amazonaws.com/thumbnails/services-and-http.jpg", | |
"longDescription": "<p class='course-description'>Build Services using Observables, learn to use the HTTP module effectively.", | |
"url": "angular2-http" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requestLessonDeletion(lessonId:string, courseId:string) { | |
this.db.child('queue/tasks').push({lessonId,courseId}) | |
.then( | |
() => alert('lesson deletion requested !') | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Running consumer ..."); | |
const lessonsRef = database().ref("lessons"); | |
const lessonsPerCourseRef = database().ref("lessonsPerCourse"); | |
const queueRef = database().ref('queue'); | |
const queue = new Queue(queueRef, function(data, progress, resolve, reject) { | |
console.log('received delete request ...',data); | |
... complex business logic goes here ... | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"url": "angular2-hello-world-write-first-application", | |
"description": "Angular 2 Tutorial For Beginners - Build Your First App - Hello World Step By Step", | |
"duration": "2:49", | |
"tags": "BEGINNER", | |
videoUrl: "https://www.youtube.com/embed/du6sKwEFrhQ", | |
"longDescription": "This is step by step guide to create your first Angular 2 application. Its aimed at beginners just starting out with the framework.This lesson will show how to create a component, and how to link the component to a given custom HTML tag. It will show how to give the component a given template." | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"url": "angular2-hello-world-write-first-application", | |
"description": "Angular 2 Tutorial For Beginners - Build Your First App - Hello World Step By Step", | |
"duration": "2:49", | |
"tags": "BEGINNER", | |
videoUrl: "https://www.youtube.com/embed/du6sKwEFrhQ", | |
"longDescription": "This is step by step guide to create your first Angular 2 application. Its aimed at beginners just starting out with the framework.This lesson will show how to create a component, and how to link the component to a given custom HTML tag. It will show how to give the component a given template." | |
lessons: [ | |
{ | |
"url": "angular2-hello-world-write-first-application", | |
"description": "Angular 2 Tutorial For Beginners - Build Your First App - Hello World Step By Step", | |
"duration": "2:49", | |
"tags": "BEGINNER", | |
videoUrl: "https://www.youtube.com/embed/du6sKwEFrhQ", | |
"longDescription": "This is step by step guide to create your first Angular 2 application. Its aimed at beginners just starting out with the framework.This lesson will show how to create a component, and how to link the component to a given custom HTML tag. It will show how to give the component a given template." | |
}, | |
{ | |
"url": "angular2-build-your-first-component", | |
"description": "Building Your First Angular 2 Component - Component Composition", | |
"duration": "2:07", | |
"tags": "BEGINNER", | |
videoUrl: "https://www.youtube.com/embed/VES1eTNxi1s", | |
"longDescription": "In this lesson we are going to see how to include a component inside another component. We are going to create a simple search box component and include it in our main application." | |
}, | |
... | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor( @Inject(FirebaseApp) fb) { | |
const rootDbRef = fb.database().ref(); | |
rootDebRef.child('courses').on('value', | |
snap => console.log('Received the whole courses node',snap.val()) ); | |
rootDebRef.child('lessons/-KT_udWS6pEmpLVrxlVw:').on('value', | |
snap => console.log('Received lesson with a given Id',snap.val()) ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
findLessonById(lessonId:string):Observable<Lesson> { | |
return this.db.object(`lessons/${lessonId}`) | |
.map(Lesson.fromJson); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {initializeApp,database} from 'firebase'; | |
export const firebaseConfig = { | |
apiKey: "AIzaSyA0BcUcu4V8aHT_gM-32BhRcmqji4z-xts", | |
authDomain: "some-app.firebaseapp.com", | |
databaseURL: "https://some-app.firebaseio.com", | |
storageBucket: "some-app.appspot.com", | |
messagingSenderId: "290354329699" | |
}; | |
initializeApp(firebaseConfig); | |
database().ref().on('value', snapshot => console.log(snapshot.val())); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
courses$.push({description: 'New Course'}) | |
.then( | |
() => console.log('item added'), | |
console.error | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment