Omnibus 0.0.6 released: New helper functions to simplify event handling

Kacper Kula
2 min readMar 12, 2022

--

The new version of Omnibus is out with set of new helper functions. You can now delay, filter, skip duplicates as well as debounce and throttle your events. In this article I will give a quick rundown of how you can use those in practice.

If it’s the first time you hear about omnibus, I recommend reading my other article where I describe it’s main concepts:

Delay

You can use delay function to delay an event by certain time. The following code will trigger ping / pong in turns every 500ms (0.5s).

Filter

You can filter certain events using filter helper function:

Optionally you can use second argument passed to filter function that is the value of the previous successful call. The following code will only log powers of 2:

Skip Duplicates

Skip duplicates will skip all duplicated events appearing in a row. It’s good if you want to subscribe only to change of a parameter.

Let’s imagine you want to detect if the mouse moved between 100x100px quadrants on the page. You can achieve it in the following way:

--

--