Skip to content

Commit

Permalink
store the promises
Browse files Browse the repository at this point in the history
  • Loading branch information
Olaf Kwant committed Sep 21, 2018
1 parent be5314f commit 88f6a5c
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/client_v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,7 @@ export default class ClientV2 extends Client {
delete obj.cachable
var cacheName = tools.unqiue(obj)

if (cached) {
var currently = tools.cache(cacheName)
if (currently !== undefined) return Promise.resolve(currently)
}

return Client.prototype.request.call(this, obj).then((data) => {
if (cached) tools.cache(cacheName, data)
return data
})
if (cached) return tools.cache(cacheName) || tools.cache(cacheName, super.request(obj))
else return super.request(obj)
}
}

0 comments on commit 88f6a5c

Please sign in to comment.