In Angular 1 promises guaranteed that you will receive the response, but only once. Working with Firebase needs response working as STREAMS.
Zones + Change Detection Zones - Asynchronous execution context. It let you know when the synchronous action are completed. Also Zones will allow to have continuous stack-trace of errors. Change Detection - will take a look at what is changed and it knows what to do with it.
Pipes
It is like Filters in Angular 1, but now they can manage state.
You can take URL where is your data and pipe it, so that it could be used in your template. When data changes then your its value automatically changes in your template.
Observables
Promises will give you callback just one time. Observables will fire off as a continuous stream, it is like a promises but they continue to fire off.
Installation npm install --save angularfire2 npm install --save angular-cli ng new my-awesome-app cd my-awesome-app ng serve
1. Instantiate our Firebase URL
For instance AngularfireDemoApp is a component. Everything in Angular 2 is based on Components.
bootstrap(AngularfireDemoApp, [ defaultFirebase('https://FB-URL.firebase.com'), FIREBASE_PROVIDERS ]);
2. Push data to Firebase
return PromiseObservable .create(this._fbRef.child('message').push({ message, user }));
Pipes - transform data as input a desired output
Statless pipes - transform data without remembering or detecting anything about it Stateful pipes (async) - receive a Promise or Obsorvable as input, maintain a subscription to that
Stateful pipes (async) - example of use Async Pipes in html template: '<div *ngFor="#message of messages | async"><div>'
Angular application could save Work In Process files (WIP) in Local Storage. The Breeze framework is widely used for this purpose. John Papa gives good explanation how it works:
https://www.youtube.com/watch?v=JLij19xbefI
Principles: Separation of Concerns: 1 Component, 1 Role, 1 File LIFT: Locating our code is easy Identifying code at a glance Flat structure as long as we can Try to stay DRY