Today we released the latest edition of our Monster project. Monster is a collection of javascript classes that we need for daily work in our web projects.
Besides small helper functions and classes, it also provides useful functions to enable reactive programming.
Monster is available via jsdelivr and npm.
Only the highlights are described here. The full functionality can be found in the documentation.
New class DeadMansSwitch
With the help of the dead man switch you can execute a function after a certain time. this is useful for example if you don't know how many events will be fired, but you only want to react to the last one of a series.
import {DeadMansSwitch} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.29.0
/dist/modules/util/deadmansswitch.js';
const deadmansswitch = new DeadMansSwitch(100, ()=>{
console.log('yeah!')
// ↦ "yeah!"
})
deadmansswitch.touch(); // from here wait again 100 ms
deadmansswitch.touch(200); // from here wait 200 ms
hope you enjoy it!
Top comments (2)
the functionality of DeathManSwitch is similar to underscores throttle right?
I am not that familiar with underscore, but if i understand the documentation correctly, then yes.