Skip to content

Instantly share code, notes, and snippets.

@simonschwartz
Last active April 7, 2019 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonschwartz/c00a61df93ba08c1a74ce43f1e448e6f to your computer and use it in GitHub Desktop.
Save simonschwartz/c00a61df93ba08c1a74ce43f1e448e6f to your computer and use it in GitHub Desktop.
import { createRequest } from 'request-state-wrapper';
const getNodeRepoDetails = () =>
fetch('https://api.github.com/repos/nodejs/node').then(response => response.json());
const getGoRepoDetails = () =>
fetch('https://api.github.com/repos/golang/go').then(response => response.json());
const request = createRequest({
request: [getNodeRepoDetails, getGoRepoDetails],
stalledDelay: 1000,
onStalled: () => { /* handle stalled state */ },
});
// Run it!
request()
.then(response => {
const [ nodeResponse, goResponse ] = response;
/* handle request response */
})
.catch(error => { /* handle request error */ });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment