A live Twitter search listing
As a slightly more practical example, let's build a simple Twitter search page that could be used to show updates for a particular hashtag or search term.
Since we're dealing with dynamic content, this is going to need some server-side processing. It will work like this:
- The server will perform a search via the Twitter API.
- The set of tweet statuses returned by the API will be output as
amp-live-list
child items, with the unique tweet ID used as theid
of theamp-live-list
items, and the tweet time used as thedata-sort-time
. - The
amp-live-list
component will then poll the server from the client's browser at 15-second intervals. This will cause the server to search via the Twitter API again, and build the AMP page again. The browser basically fetches this page in the background, but doesn't render it. - If
amp-live-list
detects any new tweets in the latest response from the server, the update button will be shown. - When the update button is tapped, any new item will be...