Lil Rose
1 min readJul 16, 2020

--

Here's the method I use to keep asynchronus calls (and even global variables) functional (translated from the language I typically use).

function getEthinUSD( ethPrice = async function (return await api.ethPrice('USD)){

return ethWallet*ethPrice

}

Boom, it's functional. The secret-sause is keep dynamically changing parts as defaults in the parameters. This means when you have a broken return, it's not the function that's broken, but the passed-in variable, and if it's broken, it's a different variable you're passing in. I have found this one of the biggest tricks to converting procedural and object oriented code into functional.

--

--

Lil Rose
Lil Rose

Written by Lil Rose

Politics: [Glasdog (Geo-Libertarian Anarcho-Socialist for Directly Organized Governance)] Gender:[Trans Woman] Sexuality: [Bisexual] Religious views: [Neophist]

No responses yet