Home
Blog Author Picture

Luka Vidaković

Web is the ultimate place for applications and services

Measure time with a higher order utility function

Mar 2, 20201 min read

I consider closures and higher order functions to be one of the most powerful language features, if not the most powerful. Here is a 2-liner function that uses both of them. Comes in handy for testing, debugging and measuring performance of some chun...

takeLatest Promise util function

Dec 9, 20193 min read

On frontend, you may have a piece of code that rapidly fires network requests, based on user interaction. Debouncing such actions becomes less and less a viable option because of user experience. Especially with advent of React.js Suspense which deal...

Communicating with an iframe — postMessage bare bones example

Nov 25, 20194 min read

I keep forgetting how communication between a main window and an iframe works because I don't use it so often. Most articles go in depth of how and why, rather than serve as a quick recap, so I'll try to do that here. main window and an iframe can e...

Timeout mechanism using Promise.race

Nov 22, 20191 min read

Let's build on top of simple one-liner I've written about previously that allows you to pause code execution. Here it is one more time: const pause = time => new Promise(resolve => setTimeout(resolve, time)) Simply combine it with Promise.race functi...

One-line pause function in plain Javascript

Nov 19, 20191 min read

To keep it short, this post only deals with a simple pause function: const pause = time => new Promise(resolve => setTimeout(resolve, time)) pause function returns a Promise when called. The Promise itself resolves after a specified amount of time, ...

Shortwire the async/await's catch

Nov 18, 20192 min read

Handling exceptions in the async/await functions can become really bothersome. You can have multiple await calls inside a function for which you need to handle exceptions separately. This requires either wrapping every await call inside its own try/c...

© 2021 Web Mentality

PrivacyTerms
Proudly part of