Mastering JavaScript Functional Programming by Federico Kereki

Mastering JavaScript Functional Programming by Federico Kereki

Author:Federico Kereki
Language: eng
Format: epub, mobi, pdf
Tags: COM060160 - COMPUTERS / Web / Web Programming, COM051260 - COMPUTERS / Programming Languages / JavaScript, COM051010 - COMPUTERS / Programming Languages / General
Publisher: Packt
Published: 2017-11-29T09:51:17+00:00


const myFetch = partial(fetch, undefined, myParameters);

// undefined means the first argument for fetch is not yet defined

// the second argument for fetch() is set to myParameters

myFetch("a/first/url").then(/* do something */).catch(/* on error */);

myFetch("a/second/url")

.then(/* do something else */)

.catch(/* on error */);

If the request parameters had been the first argument for fetch(), currying would have worked. (We'll have more to say about the order of parameters later.) With partial application, you can replace any arguments, no matter which, so in this case myFetch() ends up as a unary function. This new function will get data from any URL you wish, always passing the same set of parameters for the GET operation.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.