Created
April 26, 2016 20:55
-
-
Save ryanflorence/f4ea16304a04c9430ab9bfebac3e4a87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cache = {} | |
export default getJSONWithCache(url) { | |
return cache[url] ? | |
Promise.resolve(cache[url]) : | |
getJSON(url).then(json => { | |
cache[url] = json | |
return json | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment