Book Image

Learning Single-page Web Application Development

Book Image

Learning Single-page Web Application Development

Overview of this book

Table of Contents (15 chapters)
Learning Single-page Web Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Event-driven development and the event loop


Event-driven development came from event-driven programming, in other words, outside the paradigm of object-oriented programming, event-based programming is the ability to treat the application flow after an event is fired.

JavaScript is a great language for event-driven programming; it allows anonymous functions and closures, and more importantly, the syntax is very familiar with other programming languages. The callback functions that are called when an event occurs can be written in the same place where you capture the event. Therefore, it is easy to code and easy to maintain your application.

Almost everything in Node uses callbacks. Node callbacks are functions that will be implemented in the asynchronous mode. In general, a callback function is one that is passed as an argument to another function using function pointers. For example, it tells a function to perform some task and when finished with this task, perform another task.

The event loop...