Forked from ryanflorence/gist:f4ea16304a04c9430ab9bfebac3e4a87
Created
May 25, 2016 07:08
-
-
Save slmyers/6ed98476a0eac71c76117e2b2275eaf2 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