Книги и журналы » Компьютерная литература » Программирование (книги)
Web API CookbookГод издания: 2024
Автор: Attardi J.
Издательство: O’Reilly
ISBN: 978-1-098-15069-3
Язык: Английский
Формат: PDF/ePub
Качество: Издательский макет или текст (eBook)
Интерактивное оглавление: Да
Количество страниц: 345
Описание: javascript gives web developers great power to create rich interactive browser experiences, and much of that power is provided by the browser itself. Modern web APIs enable web-based applications to come to life like never before, supporting actions that once required browser plug-ins. Some are still in an experimental stage, but many are ready for use today.
With this hands-on cookbook, author Joe Attardi helps you explore the powerful APIs available in modern browsers and guides you through the specific tasks that they unlock. Because these features are web standards, there is comprehensive documentation available from trusted resources such as MDN Web Docs. The knowledge you'll gain is transferable across different companies and projects.
A Web API is a series of global objects and functions exposed by the browser. Your javascript code can use these to interact with the Document Object Model (DOM), perform network communication, integrate with native device features, and much more. A lot of the APIs covered in this book are asynchronous. When you call one of these functions or methods, you might not get the result back right away. Different APIs have different mechanisms to get the result back to you when it’s ready. The most basic asynchronous pattern is a callback function. This is a function that you pass to an asynchronous API. When the work is complete, it calls your callback with the result. Callbacks can be used on their own or as part of other asynchronous patterns.
Many newer APIs use Promises. A Promise is an object, returned from a function, that is a placeholder for the eventual result of the asynchronous action. Instead of listening for an event, you call then on a Promise object. You pass a callback function to then that is eventually called with the result as its argument. To handle errors, you pass another callback function to the Promise’s catch method. A Promise is fulfilled when the operation completes successfully, and it is rejected when there’s an error. The fulfilled value is passed as an argument to the then callback, or the rejected value is passed as an argument to the catch callback.
Supplemental material (code examples, exercises, etc.) is available for download at GitHub.com.
• Learn the breadth of functionality available in modern browser APIs
• Explore future APIs that are still in an experimental stage
• Discover newer elements, such as dialog that replaces the need for a third-party library
• Build more powerful and interactive web applications using native APIs
• Understand the permissions model used by the browser to unlock functionality such as geolocation and push notifications
[spoiler="Примеры страниц (скриншоты)"]

[/spoiler]