Skip to content

Instantly share code, notes, and snippets.

@jaredatron
Last active October 24, 2017 22:01
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 jaredatron/5a4140d71c7679574da819a781a7589a to your computer and use it in GitHub Desktop.
Save jaredatron/5a4140d71c7679574da819a781a7589a to your computer and use it in GitHub Desktop.
const doSomething = (uniqueThing) => {
if (doSomething.currentRequest[uniqueThing]) {
return doSomething.currentRequest[uniqueThing]
}
return doSomething.currentRequest[uniqueThing] = require(url, params)
.then(
response => {
delete doSomething.currentRequest
return response
},
error => {
delete doSomething.currentRequest
throw error
}
)
}
doSomething.cache = {}
@daschi
Copy link

daschi commented Oct 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment