- From: Jake Archibald <notifications@github.com>
- Date: Sat, 06 Aug 2016 08:22:30 -0700
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
Received on Saturday, 6 August 2016 15:23:01 UTC
@wheresrhys seems like a singleton-style pattern would be better: ```js const getFlags = (() => { let cacheTime; let cachedFlags; return function getFlags() { if (cachedFlags & Date.now() - cacheTime < 1000 * 60 * 5) { return Promise.resolve(cachedFlags); } return getFlagsFromIDB().then(flags => { cachedFlags = flags; cacheTime = Date.now(); return cachedFlags; }); }; })(); ``` --- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/slightlyoff/ServiceWorker/issues/756#issuecomment-238028525
Received on Saturday, 6 August 2016 15:23:01 UTC