Preventing a function from being called twice in Typescript

--

When using Promises, there are times when we can’t be sure whether a long-running function has returned and is ready to be called again. In cases like these, we want a logic that says: “if this function has not returned, do not call it again.”

Luckily, this can be implemented through typescript decorators like so:

--

--

Michael Michailidis
Michael Michailidis

Written by Michael Michailidis

I am a software engineer working in Node.js + iOS with an eye for blockchain applications!

No responses yet