Book Image

Meteor Cookbook

By : Isaac Strack
Book Image

Meteor Cookbook

By: Isaac Strack

Overview of this book

Table of Contents (19 chapters)
Meteor Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Handling asynchronous events


Meteor is a reactive framework. As you've probably noticed, it's built on top of Node.js, but when writing or using packages, it somehow magically avoids all of the callback and event loop drama you'd normally face with Node.js. Meteor lets you code in a declarative, synchronous-like style. This recipe will show you one of the ways Meteor does this, and how you can handle asynchronous events coming in from a third-party package. In this case, we will read an incoming Twitter stream from the npm twit package.

Getting ready

We need to quickly set up a test application on Twitter and load the npm twit module, so we'll do that here, so as not to distract from the recipe itself. Note that you can use any asynchronous event stream you would like for this recipe, including the standard setInterval() method, which could be used to mimic an asynchronous event stream.

Creating a baseline Meteor app

Open a terminal window, navigate to where you would like your project to reside...