Previously, in order to detect updates in the database, you would have to send a new query for every update. With observable streams, you "watch" the stream, which means you're passively listening for an event. This allows you to detect changes instantly without unneccessary network calls.
- [Instructor] Let's talk for a minute about database observables. Real-time data. Not too long ago this was impressive, cutting-edge technology. Nowadays it's become standard, expected. But how does this affect databases? Well, before real-time updates, databases were just sitting there holding the data and waiting for a query to come in. When it received a query it would gather up all the data and return results and then go back to waiting. Nowadays, we don't want our databases to sit around passively waiting for a query.
We want our databases to notify us anytime something has changed. And now that this behavior has become standard, we're changing the way we interact with databases. We can still query the database just like we always did, but now we can also listen for updates. This is actually great because not that long ago, if we wanted real-time updates, the only way to achieve that was to keep pinging the database over and over and then look for changes. Now we can just sit back and listen, which really reduces the amount of unnecessary traffic on the network. Just one more thing.
As technology evolves, we get new buzz words. Now that we're listening for dynamic data, we refer to this as a data stream. According to Wikipedia, a stream is a sequence of data elements made available over time. A stream can be thought of as items on a conveyor belt being processed one at a time rather than in large batches. Remember the marble diagrams we talked about in the last video? Okay, marble diagrams, data streams, same same. Each new update is an event, usually carrying with it some new data also known as a payload.
- Creating observables with rx.observable.create
- Subjects, including behavior and replay subjects
- RxJS operators
- Creating an observable from a UI element