Month: April 2018

Emulate Thread.sleep() in JavaScript

When you’re writing code in JavaScript and you need your function to wait some time, you usually use setTimeout(callback, millis). The problem with this function is that only the callback will be delayed, while the code next to it will run normally. How do you actually stop the execution of the application for a certain amount of time, like Java’s Thread.sleep() does?

You can do that thanks to ES8.

(more…)

Web push notifications with Node.js, Angular and Express

I’m currently working on the development of a very basic PWA. During the first day I’ve managed to correctly implement the code to handle geolocalization and access to the camera. After that, it was time to take a look at push notifications. I’ve started reading about them and mocked some quick code to test. It was then that I realized the process will not be as easy as I hoped.

But after three long and painful days I’ve finally managed to make them work.

(more…)