Skip to content

0.2.10

Compare
Choose a tag to compare
@zackify zackify released this 08 Mar 15:57
· 4 commits to master since this release

Block requests by returning false from a url function, heres the use case!

You can globally prevent duplicating requests within the same time period.

let lastUrl;

const onURL = url => {
  //block repeat requests within a second of each other
  if (url === lastUrl) return false;
  lastUrl = url;
  setTimeout(() => lastUrl = '', 1000);
  return url
};

let response = await partial`
  url: ${onURL}
`;

//request was made multiple times in a second, return false!
if(response.requestBlocked) return false