HomeSoftware DevelopmentMonitor Occasions and Operate Calls by way of Console

Monitor Occasions and Operate Calls by way of Console

Regardless of having labored on the very advanced Firefox for a variety of years, I will at all times love plain outdated console.log debugging. Logging can present an audit path as occasions occur and textual content you possibly can share with others. Do you know that chrome offers monitorEvents and monitor so to get a log every time an occasion happens or perform is known as?

Monitor Occasions

Cross a component and a collection of occasions to monitorEvents to get a console log when the occasion occurs:

// Monitor any clicks inside the window
monitorEvents(window, 'click on')

// Monitor for keyup and keydown occasions on the physique
monitorEvents(doc.physique, ['keyup', 'keydown'])

You possibly can go an array of occasions to pay attention for a number of occasions. The logged occasion represents the identical occasion you’d see should you manually known as addEventListener.

Monitor Operate Calls

The monitor technique permits you to pay attention for calls on a particular perform:

// Outline a pattern perform
perform myFn() { }
// Monitor it

// Utilization 1: Fundamental name
// perform myFn known as

// Utilization 2: Arguments
// perform myFn known as with arguments: 1

I actually like which you could view the arguments offered, which is nice for inspecting.

I often go for logpoints as an alternative of embedding console statements in code, however monitor and monitorEvents present an alternative choice to each.

  • Write Simple, Elegant and Maintainable Media Queries with Sass
  • Tips for Starting with Bitcoin and Cryptocurrencies

    One of the vital rewarding experiences of my life, each financially and logically, has been shopping for and managing cryptocurrencies like Bitcoin, Litecoin, Ethereum. Like studying every other new tech, I made rookie errors alongside the way in which, however realized some greatest practices alongside the way in which. Try…

  • Using Opacity to Show Focus with MooTools
  • Link Nudging with CSS3 Animations

    One of many extra well-liked and easy results I’ve featured on this weblog over the previous 12 months has been linking nudging.  I’ve created this impact with three flavors of JavaScript:  MooTools, jQuery, and even the Dojo Toolkit.  Fortunately CSS3 (virtually) permits us to ditch…



Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments