O'Reilly logo

React 16 Tooling by Adam Boduch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The API abstraction

For this application, I'm using a simple API abstraction. In Redux apps, you should be able to have your asynchronous functionality—API or otherwise—encapsulated in its own module or package. Here's what the api.js module looks like, with some of the mock data redacted for brevity:

const LATENCY = 1000; const BOOKS = [ { title: 'React 16 Essentials', author: 'Artemij Fedosejev', imgURL: 'big long url...' }, ... ]; export const fetchBooks = () => new Promise(resolve => { setTimeout(() => { resolve(BOOKS); }, LATENCY); }); export const createBook = (title, author, imgURL) => new Promise(resolve => { setTimeout(() => { BOOKS.push({ title, author, imgURL }); resolve(); }, LATENCY); }); export const fetchBook = title => new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required