HTML and CSS Reference
In-Depth Information
Whether you are using Pusher or any other realtime web technology, the browser developer tools are an essential
part of your developer arsenal. Using the functionality we've discussed, such as using console.log to keep track of
which parts of your code are being invoked, and checking variable values is a first simple step, breaking into executing
code using either browser dev tool breakpoints or the debugger statement can also be very handy.
If you are using a third-party library, as we are here with the Pusher JavaScript library, it's essential that the library
exposes a way of keeping track of what it's doing. The Pusher library does this by exposing a Pusher.log property as
part of its API. As a final exercise, let's see how we use this—it may come in handy as you build your application.
eXerCISe 3-3: pUSher LOGGING
as with most pusher functionality, exposing the logging within the pusher Javascript library is very easy. all you
need to do is assign a function to the Pusher.log property. add the following code to the init.js file:
Pusher.log = function( msg ) {
if( console && console.log ) {
console.log( msg );
If you now navigate to the htML file in your browser and open your Javascript console, you'll see the pusher
Javascript library logging information that can be very useful during development (see Figure 3-8 ). as with most
development logging, you should consider removing this logging functionality before you move your application
into production.
Figure 3-8. Logging from the internal workings of the Pusher JavaScript library
Search WWH ::

Custom Search