I'm now reading "mostly adequate guide to functional programming" by Professor Frisby, and I was wondering how can we do pure fetching, and I saw this piece of code here in the book
const pureHttpCall = memoize((url, params) => () => $.getJSON(url, params));
And says
The interesting thing here is that we don't actually make the http call - we instead return a function that will do so when called. This function is pure because it will always return the same output given the same input: the function that will make the particular http call given the url and params.
where that left me with some confusion, I don't understand how pureHttpCall
is now pure and still have impure underlying code (the fetching part).
So what am I missing here that makes the code pure and functional?