Responding to change

Firebase's cloud database is not just a database that looks like JSON, it also pushes out the data when it changes. You can listen for when that happens. This gives you not only cloud storage, but also the opportunity to build applications in a more collaborative and real-time manner. A lot of systems out there work like this already, such as most ticketing systems, chat applications, and so on. 

Imagine a system built with Firebase that, for example, books movie tickets. You would be able to see when a person books a ticket, or an incoming message in a chat system, without polling logic or refreshing the app; it would be almost child's play to build.

AngularFire2, the Angular framework on top of Firebase, uses Observables. Observables convey changes when they happen. From before, we know that we can listen to such changes by giving a subscribe method a callback, like so:

this.angularFireDatabase
.list('/tickets')
.valueChanges()
.subscribe(tickets => {
// this is our new ticket list
});

What you can do as a developer is intercept when such a change happens, by signing up to the subscribe() method, and for example, show a CSS animation to draw the user's attention to the change, so they can respond accordingly. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset