Lesson 3
Requests and subscriptions
How subscriptions keep you updated on the XRPL

Now that we know a little about getting information from the ledger using requests, lets look into the concept of a subscription.
You can think of a subscription just like a request. It doesn’t sign a transaction, and it’s purely meant to query the ledger for information. But, instead of sending a ping to the ledger each time you want to retrieve information, a subscription lets you stay connected to the ledger and it sends you an update any time the ledger changes. You can create multiple simultaneous subscriptions to keep track of multiple accounts’ activity at the same time.
A quick intro to the nice-XRPL library
To build this we’ll use the nice-xrpl React library which has some simple hooks into xrpl.js. xrpl.js is the main library for interacting with the ledger using Javascript. Nice-XRPL is a React.js powered library which extends xrpl.js and focuses on building wallet-based dApps and web apps. Its core strength is in abstracting some of the XRPL.js functionality to make building a reactive UI quickly and intuitively. One of React’s big advantages is that it focuses on reactive components, which automatically update when server data (or ledger data) changes without requiring you to refresh your browser.