Guest User

Untitled

a guest
Feb 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. let fetching = {};
  2.  
  3. export default (url, options = {}) => {
  4. if (fetching[url]) {
  5. return Promise.reject(`Fetch responsibly, a fetch for the same url (${url}) is already in progress (options are ignored).`);
  6. }
  7.  
  8. fetching[url] = true;
  9.  
  10. return fetch(url, options).then(response => {
  11. fetching[url] = false;
  12. return response;
  13. });
  14. };
Add Comment
Please, Sign In to add comment