Getting Started with Meteor js JavaScript Framework 2nd Edition Learn to develop powerful web applications in minutes with Meteor Isaac Strack - Download the full ebook set with all chapters in PDF format
Getting Started with Meteor js JavaScript Framework 2nd Edition Learn to develop powerful web applications in minutes with Meteor Isaac Strack - Download the full ebook set with all chapters in PDF format
https://ebookultra.com/download/getting-started-with-grunt-the-
javascript-task-runner-1st-edition-jaime-pillora/
https://ebookultra.com/download/getting-started-with-kubernetes-2nd-
edition-jonathan-baier/
https://ebookultra.com/download/getting-started-with-openshift-1st-
edition-steven-pousty/
https://ebookultra.com/download/getting-started-with-arduino-1st-
edition-massimo-banzi/
Getting Started with SAPUI5 1st Edition Miroslav Antolovic
https://ebookultra.com/download/getting-started-with-sapui5-1st-
edition-miroslav-antolovic/
https://ebookultra.com/download/getting-started-with-electronic-
projects-1st-edition-pretty/
https://ebookultra.com/download/getting-started-with-processing-1st-
edition-casey-reas/
https://ebookultra.com/download/getting-started-with-dwarf-fortress-
learn-to-play-the-most-complex-video-game-ever-made-1st-edition-peter-
tyson/
Isaac Strack
BIRMINGHAM - MUMBAI
www.it-ebooks.info
Getting Started with Meteor.js JavaScript Framework
Second Edition
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78528-554-7
www.packtpub.com
www.it-ebooks.info
Credits
Commissioning Editor
Veena Pagare Indexer
Tejal Daruwale Soni
Acquisition Editors
Subho Gupta Graphics
Jason Monteiro
James Jones
Production Coordinator
Content Development Editor
Manu Joseph
Anish Sukumaran
Cover Work
Technical Editor
Manu Joseph
Menza Mathew
www.it-ebooks.info
About the Author
www.it-ebooks.info
About the Reviewers
Arthur Pham has been working for Thomson Reuters as a lead quantitative
engineer since 2006. He has spent many years designing and implementing
derivative pricing models and still loves to learn new programming languages
such as F#, C++, Python, Flex/ActionScript, C#, Ruby, and JavaScript.
He currently lives in New York, USA, and can be contacted on twitter at @arthurpham.
www.it-ebooks.info
www.PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at [email protected] for more details.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
www.it-ebooks.info
Table of Contents
Preface v
Chapter 1: Setup and Installation 1
Installing using curl 2
Loading an example application 3
Selecting your file's location 4
Loading the example application 4
Starting the example application 4
Previewing the application 5
Help! I made too many changes! 6
Making code changes 6
Changing from Leaderboard to Yay Science! 7
Summary 10
Chapter 2: Reactive Programming…It's Alive! 11
Creating the Lending Library 11
Creating the base application 12
Creating a Collection 14
Having fun with the browser console 15
Adding some data 17
Displaying collections in HTML 18
Cleaning up 22
Creating a reaction 25
Multiple clients 27
Summary 28
[i]
www.it-ebooks.info
Table of Contents
[ ii ]
www.it-ebooks.info
Table of Contents
[ iii ]
www.it-ebooks.info
www.it-ebooks.info
Preface
We live in amazing times. Advances in medicine, communication, physics, and
all other scientific fields provide us with opportunities to create things that were
literally impossible to create only a short while ago.
Yet, we aren't easily amazed. Moore's law has not only affected how fast our
computers are, it has significantly increased our expectations as well. We've
come to expect wondrous advances, and therefore, what was once amazing has
become…well…expected. It's a rare thing, indeed, to find something that takes
us by surprise—something that renews that childhood sense of wonder we all
secretly want back because it was stolen from us.
Well, get ready to regain some of that wonder. A dedicated group of computer
scientists, who were determined to make something wondrous, have created a
new JavaScript framework called Meteor. You may be thinking, "A new JavaScript
framework? That's nothing special." And, if that's all Meteor is, you'd be correct.
However, fortunately for you, that's not the end of the story.
[v]
www.it-ebooks.info
Preface
And the best part is, it's simple to learn, amazingly simple! You will see an
application come to life right before your eyes, and when you look back at the
number of lines of code it took to create and compare it to the traditional methods
of development, you may actually find yourself saying "wow" or "how did they
do that?"
This book will walk you through the major features of Meteor and show you
how to create an application from scratch. By the end of the book, you will have
created a working, useful application, and you will have a solid understanding of
what makes Meteor different. This may sound like hyperbole, but if you're open
to the idea that something innovative and unexpected can qualify as amazing,
then prepare to be amazed!
Chapter 3, Why Meteor Rocks!, helps you to gain an understanding of the design
patterns that Meteor uses and see examples of these powerful patterns in action.
Chapter 4, Templates, teaches you about Meteor Templates in depth and uses
templates to lay the groundwork for your Lending Library application.
Chapter 5, Data – Meteor Style!, helps you to discover how Meteor handles data,
making an enterprise-level application incredibly simple and robust. Implement
Meteor's data handling quickly and effectively in your application.
Chapter 6, Application Structure – Client, Server, and Public (oh my!), shows you what
changes you can make to the default configuration to make your application more
secure, extensible, and user-friendly.
[ vi ]
www.it-ebooks.info
Preface
• Operating systems:
°° Mac OS X 10.7 (Lion) and above versions
°° Linux x86 or x86_64 architectures
°° Windows 7 and above versions
• Meteor:
°° Meteor version 1.1 or above
The following table will guide you to sites that contain more information:
If you are looking for a step-by-step approach to understand how and when to
use one of the most popular and innovative application development frameworks,
this book is for you.
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
Code words in text are shown as follows: "The WebElement class also supports
find methods to find child elements."
[ vii ]
www.it-ebooks.info
Preface
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
//Locate all the Checkbox which are checked by calling jQuery
find() method.
//find() method returns elements in array
List<WebElement> elements = (List<WebElement>)
js.executeScript("return jQuery.find(':checked')");
New terms and important words are shown in bold. Words that you see on
the screen, in menus or dialog boxes for example, appear in the text like this:
"Right-click to open the pop-up menu and select the Inspect element option."
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.
[ viii ]
www.it-ebooks.info
Preface
Customer support
Now that you are the proud owner of a Packt book, we have a number of things
to help you to get the most from your purchase.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you would report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/support, selecting your book, clicking on the errata submission form link, and
entering the details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded to our website, or added to any list
of existing errata, under the Errata section of that title.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt, we take the protection of our copyright and licenses very seriously. If you
come across any illegal copies of our works, in any form, on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors, and our ability to bring you
valuable content.
Questions
You can contact us at [email protected] if you are having a problem with
any aspect of the book, and we will do our best to address it.
[ ix ]
www.it-ebooks.info
www.it-ebooks.info
Setup and Installation
Under the hood, Meteor is really just a bunch of files and scripts, which are designed
to make the building of a web application easier. That's a terrible way to describe
something so elegant, but it helps us to better understand what we're using.
After all, Mila Kunis is really just a bunch of tissue wrapped around bone, with
some vital organs inside. I know you hate me now for that description, but you
get the point. She's beautiful. So is Meteor. But it doesn't do us any good to just
leave it at that. If we want to reproduce that type of beauty on our own, we have
to understand what's really going on.
So, files and scripts… We're going to walk you through how to get the Meteor package
properly installed on your Linux or Mac OS X system, and then see the package of files
and scripts in action.
[1]
www.it-ebooks.info
Setup and Installation
curl (or cURL if you want to get fancy) is a command-line tool used to transfer
files and run scripts using standard URL locations. You probably already knew that,
or you probably don't care. Either way, we've described it and we're now moving on
to using it.
Open a terminal window or the command line, and enter the following command:
curl https://install.meteor.com/ | sh
This will install Meteor on your system. curl is the command to go and fetch the
script. https://install.meteor.com is the URL/location of the script, and sh is,
of course, the location of the script interpreter "Shell", which will run the script.
Once you've run this script, assuming you have an Internet connection and the
proper permissions, you will see the Meteor package downloaded and installed:
[2]
www.it-ebooks.info
Chapter 1
The key thing that we're looking for in the preceding installation text is the launcher
script location:
Writing a launcher script to /usr/local/bin/meteor
This location could vary depending on whether you're running this script in Linux
or Mac OS X, but it puts Meteor into a location where you can then access the Meteor
script from anywhere else. This will become important in a minute. For now, let's see
what kind of friendly message we get when the Meteor installation is finished:
To get started fast:
docs.meteor.com
Great! You've successfully installed Meteor, and you're on your way to create your
first Meteor web application!
We want to use the simplest possible example, just to get an idea of how Meteor
works, so we will be creating the leaderboard example. We'll be using the command
line again. This is awesome news if you still have it open! If not, open a terminal
window and follow these steps.
[3]
www.it-ebooks.info
Setup and Installation
As with the Meteor installation itself, the create command script has a friendly
success message:
leaderboard: created.
To run your new app:
cd leaderboard
meteor
There are even instructions on what to do next. How handy! Let's go ahead and do
what our good command-line friend is telling us.
[4]
www.it-ebooks.info
Chapter 1
Yes, that's it. Meteor takes care of everything for us; it reads all the files and scripts,
and sets up the HTTP listener:
[[[[[ ~/Documents/Meteor/leaderboard ]]]]]
We can now take the URL we've been given (http://localhost:3000/) and check
out the example application in a web browser.
You should see a screen with a list containing the names of scientists, similar to the
following screenshot:
[5]
www.it-ebooks.info
Setup and Installation
You can go ahead and poke around the application a bit, if you want to. Click on
Nikola Tesla's name and add 5 points to his score about 20 bajillion times, because
he deserves it. Give some love to Marie Curie because she was so radioactive that
she actually made up the word. Go nuts, friend!
3. Restart your app, and you're good to go. Just type the following command:
$ meteor
Note that the initial scores are random, so it won't look exactly like it did before.
The meteor reset command resets all the data collections and whatnot; so in a
non-random app, the command will indeed reset the app cleanly.
One of the best features of Meteor is reactive programming. The following extract is
taken from http://docs.meteor.com/#/full/reactivity:
Meteor embraces the concept of reactive programming. This means that you can
write your code in a simple imperative style, and the result will be automatically
recalculated whenever data changes that your code depends on.
This principle applies to code changes too, which means that any changes
that you make to the HTML, JavaScript, or database are automatically picked
up and propagated.
You don't have to restart the application or even refresh your browser. All changes
are incorporated in real time, and the application reactively accepts the changes.
[6]
www.it-ebooks.info
Chapter 1
To see what we mean, let's change the title of this application from Leaderboard to
Yay Science! because, well, yay science!
First, make sure that the application is up and running. You can do this by having
an open browser window that is pointing to http://localhost:3000/. If the
app is running, you'll see your leaderboard application. If your application isn't
running, make sure to follow the steps previously given in the Starting the example
application section.
Now, we need to open and edit the leaderboard.html file. With your favorite text/
code editor, open the leaderboard.html file under the location, ~/Documents/
Meteor/leaderboard/client/, and change title in the head section using the
following lines of code:
<head>
<title>Yay Science!</title>
</head>
Go ahead and save the file, and then look at your web browser. The page will
automatically update, and you'll see the title change. Earlier, it displayed the
word Leaderboard:
However, now, after the execution of the preceding code, the title will display our
spiffy new Yay Science! page:
[7]
www.it-ebooks.info
Setup and Installation
This is Meteor in action! It monitors any changes to files, and when it sees that a file
has changed, it tells your browser that a change has been made and that it should
refresh itself to get the latest version.
Moving forward, we're going to build an application from scratch, so we don't want
to make too many changes to this example application. However, we still want to
stay with our new theme rather than that generic old leaderboard stuff. So, to do so,
perform the following steps:
1. Back in your text editor, on about the tenth line or so, we have the title
label for our leaderboard. Make the following change to the <h1> tag:
<h1 class="title">Yay Science!</h1>
Save this change, and you'll see the change reflected in your browser.
The title in our page will now look like this:
We also need to change the button text from the word points to the word
props. Towards the bottom half of the file, you'll find a <button> tag.
Change the text in that tag to the following:
<button class="inc">Give props</button>
[8]
www.it-ebooks.info
Chapter 1
Save your changes, and you will see the application update
almost immediately:
Save this change, and this time, refresh your browser. Not because we need
the change to take effect, but because we want to make sure no scientist is
highlighted so that we can verify our message text:
[9]
www.it-ebooks.info
Setup and Installation
Summary
Great success! In this chapter, you've successfully installed the Meteor framework,
loaded an example application, and made changes to that application by becoming
familiar with file changes and the reactive nature of Meteor.
You are now ready to start building your very own Meteor application, and learn
more about the elegant features and advantages that come from developing with
Meteor in the coming chapters.
[ 10 ]
www.it-ebooks.info
Chapter 2
Reactive Programming…
It's Alive!
As we learned in Chapter 1, Setup and Installation, Meteor operates on a reactive
programming model. This means that your templates aren't only concerned with
displaying data, but they are also listening for changes to that data so that they can
"react" to those changes. These areas of data where the templates look for changes
are called reactive contexts.
We will now start developing a Lending Library application, lay the framework for
future chapters, and use Meteor's built-in reactive model to track and propagate
changes to our application to all clients that are listening.
Using Meteor, we're going to build a Lending Library. We'll keep track of all our
stuff and who we lent it to, so that the next time we can't remember where we put
our linear compression wrench, we can simply look up who we lent it to last and
get it back from them.
[ 11 ]
www.it-ebooks.info
Reactive Programming…It's Alive!
And when that same friend says, "Are you sure you lent it to me?", you can say,
"Yeah, STEVE, I'm sure I lent it to you! I see you're enjoying your digital cable,
thanks to my generous lending of said linear compression wrench. Why don't you
go find it so that I too can enjoy the benefits of digital cable in my own home!"
Okay, okay, maybe STEVE forgot too. Maybe he's a dirty liar, and he sold your
wrench to pay for his deep-fried Oreo® habit. Either way, you'll have your very
own custom Meteor app that gives you proof that you're not going crazy. And, if
he did sell it for deep-fried carnival food, at least you can make him share his stash
with you while you watch the game at his house.
2. Now, we create our base folder structure for our Lending Library
application:
$ meteor create LendLib
[ 12 ]
www.it-ebooks.info
Chapter 2
5. Welcome to Meteor! is nice and all, but we are going to change this to
Lending Library. Open the LendLib.html file under ~/Documents/Meteor/
LendLib/ in your favorite editor. Towards the top (the sixth line or so), you'll
see the HTML code snippet that's responsible for our greeting. Go ahead and
change Welcome to Meteor! to Lending Library:
<body>
<h1>Lending Library</h1>
6. Save the change. The page will refresh and will look like the following
screenshot:
You may have noticed a reference to a template called hello, just below the
title:
{{> hello}}
[ 13 ]
www.it-ebooks.info
Reactive Programming…It's Alive!
7. Let's make a change in this template as well. Edit LendLib.html and modify
the title of the hello template:
<template name="hello">
<h2>my list</h2>
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>
Creating a Collection
Okay, so you've just made a few small changes to static files, but what we really
want to see is some dynamic, reactive programming, and some live HTML code!
We need to attach a data source—something that will keep track of our items.
Normally, this would be quite a process indeed, but Meteor makes it easy by
supporting MongoDB, and its own client-side version called Minimongo, out
of the box.
[ 14 ]
www.it-ebooks.info
Chapter 2
• http://en.wikipedia.org/wiki/NoSQL
• http://www.mongodb.org/
• http://www.packtpub.com/books/all?keys=mongodb
Let's create our collection. Inside the LendLib.js file under ~/Documents/Meteor/
LendLib/, we want to add the following highlighted line of code as the first line, and
then save the change:
lists = new Mongo.Collection("lists");
if (Meteor.isClient) {
...
This creates a new collection in MongoDB. Since it comes before anything else in the
LendLib.js file, the collection is available for both the client and server to see. It is
persistent, as we'll see in a moment, and once values are entered into it, they can be
retrieved by any client accessing the page.
To see this persisted object, we'll need to use the console of our web page.
[ 15 ]
www.it-ebooks.info
Reactive Programming…It's Alive!
Since we're using Chrome, the console is available by default. Let's start by
performing the following steps:
This will open our debugging tools. We now want to get into the console.
2. Click on the Console icon found at the extreme right of the debugging
menu bar:
[ 16 ]
www.it-ebooks.info
Chapter 2
You will now have a blinking cursor, and you're ready to check out our
newly minted collection!
2. Being the natural skeptics that we are, we're going to check. To do so, enter
the following command:
> lists.findOne({Category: "DVDs"});
You should then get an Object with an expandable icon next to it.
[ 17 ]
www.it-ebooks.info
Reactive Programming…It's Alive!
3. Click on this icon to expand it, and you should see something similar to the
following screenshot:
We could similarly check for our tools collection by entering the lists.
findOne({Category:"Tools"}) command, but we don't need to. This time we'll
trust that Meteor entered it correctly. We do, however, want to check to see whether
the objects are persistent. To do so, perform the following steps:
1. Refresh the web page. Your console will clear, but the Categories that we
entered have been saved in the persistent Meteor Collection, so we can check
again to see if they're hanging around.
2. Enter the following command in the console:
> lists.find({}).count();
This command finds all records in the lists collection and gives us a total
count. If everything went according to plan, you should have got back a
count of 2.
We're on our way! We've created two categories, and we have one item in each
category. We've also verified that the lists collection is being saved after each
session. Now, let's see about displaying this in our page.
[ 18 ]
www.it-ebooks.info
Chapter 2
This creates a new div element with the contents being filled by a template
partial named categories.
2. Now, at the very bottom of the page, add the skeleton for the categories:
<template name="categories">
</template>
This won't change the appearance of the page, but we now have a template
partial where we can list our categories.
3. Let's put in our section title within the preceding lines of code:
<template name="categories">
<div class="title">categories</div>
</template>
</div>
</template>
This creates the div categories which we can then go through and list all of
our categories. If we only had one record to deal with, the code would look
like this:
<div class="category">
{{Category}}
</div>
[ 19 ]
www.it-ebooks.info
Reactive Programming…It's Alive!
5. But, we need to wrap this into a loop (in this case, an #each statement) so
that we get all the categories:
<template name="categories">
<div class="title">categories</div>
<div id="categories">
{{#each lists}}
<div class="category">
{{Category}}
</div>
{{/each}}
</div>
Notice that we are telling the template "for each record in the lists collection"
with our {{#each lists}} command, and then, "display the Category" with
{{Category}}.
6. If you save these changes and look at the web page, you will see something
like the following screenshot:
This doesn't look much different. Yes, we have our header (categories), but where
are the categories for which we just created our template?
[ 20 ]
www.it-ebooks.info
Chapter 2
There's one more step we need to complete for the categories to show up. Currently,
the template that we just created isn't pointing towards anything. In other words, we
have a lists collection, and we have a template, but we don't have the underlying
JavaScript function that hooks them together. Let's take care of this by performing
the following steps:
...
Template.hello.events({ ...
These code chunks hook up JavaScript functions and objects to the HTML
hello template. Meteor's built-in Template object makes this possible, and
we're going to follow the same pattern, that is, to hook up our categories
template.
3. We've now declared the lists collection for all the templates to use, and we
can have the function return the results from a Meteor.Collection query.
We can do that using the find() command:
lists : function(){
return lists.find({}, { sort: { Category : 1 }});
}
[ 21 ]
www.it-ebooks.info
Reactive Programming…It's Alive!
This code will find every record in the lists collection and will sort the results
by the Category (name). Save these changes, and you will now see a populated
list of categories:
Cleaning up
We're fast approaching a working application, and we want it to look super-shiny
and clean. Let's do a bit of clean up in our code and add some CSS to make things
more readable. To do this, perform the following steps:
1. We don't need the greeting anymore. So, let's get rid of it. To do this,
remove the following lines from LendLib.html and save the page:
<body>
<h1>Lending Library</h1>
{{> hello}}
<div id="categories-container" class="container">
{{> categories}}
</div>
</body>
<template name="hello">
<h2>My Library</h2>
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>
[ 22 ]
www.it-ebooks.info
Chapter 2
});
Template.hello.events({
...
}); */
3. Now, let's add the Twitter Bootstrap framework, which gives us a lot of style
without much effort. Using a terminal window, create a client folder in /
LendLib/:
$ mkdir ~/Documents/Meteor/LendLib/client
Since Meteor will read and use every file put into the application folder, we want to
eliminate the redundant files. We don't have to worry too much about efficiency, but
some things are just shameful and leaving that much extraneous code lying around
is right up there with enjoying deep-fried carnival food.
1. Navigate to the Bootstrap folder (the name will vary) using the following
command:
$ cd ~/Documents/Meteor/LendLib/client/[bootstrap]/
If you know what you're doing with Bootstrap, you can just copy
the fonts, min.js, and min.css files instead of performing the
preceding instructions.
[ 23 ]
www.it-ebooks.info
Reactive Programming…It's Alive!
After all these changes, your UI should be really clean and simple:
Let's quickly make the UI more distinct and readable. To do this, we must perform
the following set of steps:
1. In LendLib.html, let's change our header from a <div> tag to an <h2> tag,
and change the text from categories to my stuff:
<template name="categories">
<h2 class="title">my stuff</h2>
[ 24 ]
www.it-ebooks.info
Chapter 2
Creating a reaction
Following the creation of our basic template and collection, and with Meteor putting
our lists collection into the reactive context, we can now proceed to watch the
reactive programming model in action.
You will instantly see the page update. Note that, this time, the full page didn't
refresh! This is because, under the hood, Meteor is tracking changes to our reactive
context (in this case, the lists collection) and the template is being updated
immediately after a change is made.
Let's make a few more changes. To do this, enter the same Fraggles command
again:
> lists.insert({Category:"Fraggles"});
But we have too many Fraggles categories now. There are a lot of Fraggles, but
unless you're some weirdo collector, you don't need two categories. So, let's remove
them. However, we can't just erase whatever we want on the client side. This is
a basic safety feature, and if we just let it happen, things could get quite chaotic.
For instance, if we tried to just remove the records using the following command:
> lists.remove({Category:"Fraggles"});
[ 25 ]
www.it-ebooks.info
Reactive Programming…It's Alive!
...then that's quite a no-no. Meteor detects stuff like this and will give us a 403 error
as follows:
There are three ways in which we can manually delete or modify records.
• The first is on the client side, by finding the ID of the record. In your browser
console, run the following command:
> lists.findOne({Category:"Fraggles"});
This will return a single record, including an _id property, similar to the
following screenshot:
• The second way is to use meteor shell. In a new terminal window (keep
your app running!), navigate to ~/Documents/Meteor/LendLib/ and enter
the following command:
$ meteor shell
This will open a console that is directly connected to the server so that we can
run commands as if they were server code; for example:
> lists.remove({Category:"Fraggles"});
This will remove all categories that are named Fraggles. The meteor shell
command comes in handy when we need to run tests or debug, so keep this
command in your pocket to use when you need it.
• The final way to delete records is how we did it in the previous chapter, with
meteor reset. In fact, let's do that right now. Stop your application from
running (Ctrl + C) and execute the following command in the terminal:
$ meteor reset
[ 26 ]
www.it-ebooks.info
Chapter 2
Start Meteor again with the meteor command, and your application screen should be
nice and clean:
It would probably be good to have a couple of categories, so let's create them really
quickly. In the browser console, enter the following commands:
> lists.insert({Category:"Collectibles"});
> lists.insert({Category:"DVDs"});
> lists.insert({Category:"Tools"});
As you can see, the changes are made instantly, with no page refresh.
Multiple clients
Good things should be shared. Meteor gets this, and as we're about to see for
ourselves, the reactive programming model allows us to share updates in real time
across multiple clients.
With your Chrome web page still open to http://localhost:3000/, open a new
browser tab and navigate to the same page.
If you really want to get fancy, you can conduct this same
experiment with multiple browsers (Firefox, Opera, or Safari).
Each session will be live and reactive!
You now have two clients open, which is simulating the application being open by
different people, at different locations, with different computers. Meteor's reactive
model allows you to treat all clients in the same manner, and a change made by one
will be propagated to all the others.
With your eyes on the new second browser, type the following command into the
console of browser #1:
> lists.insert({Category:"Vinyl Records"})
[ 27 ]
www.it-ebooks.info
Reactive Programming…It's Alive!
You will notice that the change propagates to both browsers, without a page refresh:
Feel free to make any extra collections, to remove or rename them, and so on.
Experiment a little and notice how these changes can be instantly made to every
listening client. Meteor operates under a very powerful paradigm, and in the next
chapter, you'll be able to see exactly why this is such an important and disruptive
change to web application development.
Summary
In this chapter, you successfully created the framework for your new Meteor
application. You saw firsthand how quickly a new project can be created, and you
created database and template functionality with just a few lines of code. You saw
live HTML and reactive programming in action, and you are now ready to go even
deeper into the Meteor engine. You've conquered the tip of the iceberg, my friend.
Take a break, have a cold one, and get ready for even more Meteor awesomeness!
[ 28 ]
www.it-ebooks.info
Another Random Scribd Document
with Unrelated Content
CHAPTER X
Watching Rooks
In this chapter I will give a few scenes from rook life, as I have watched it
from late autumn to early spring, linking them together by a remark now
and again of a general nature, or, possibly, some theory which my
observations may have suggested to me, and seemed to illustrate. Were I
to put into general terms what I have jotted down at all times and in all
places, in the darkness before morning when the rookery slept about me,
in the dim dawn whilst it woke into life, to stream forth, later, on wings of
joy and sound, in the long day by field and moor and waste, and at
evening again, or night, when the birds swept home and sank to sleep
amidst their own sinking lullaby, I might make a smoother narrative, but
the picture would be gone. I think it better, therefore, to make a
preliminary general apology for all roughnesses and repetitions, triviality
of matter, minuteness of detail and so forth, in fact for all shortcomings,
and then to go on in faith, not in myself, indeed, but in the rooks,
believing that they will be interesting, however much I may stand in their
way.
When I speak of the rookery I do not mean the trees where the birds
build—unfortunately there are none very near me—but those where they
come to roost during the autumn and winter—true rookeries indeed if
numbers count for anything. Here, their chosen resting-place is a silent,
lonely plantation of tall funereal firs, standing shaggily tangled together,
mournful and sombre, making, when the snow has fallen but lightly—
before they are covered—a blotch of very ink upon the surrounding white.
Who could think, seeing them during the daytime, so sad and abandoned,
so utterly still, tenanted only by a few silent-creeping tits, or some
squirrel, whose pertness amidst their gloomy aisles and avenues seems
almost an affectation—who could think that each night they were so
clothed and mantled with life, that their sadness was all covered up in joy,
their silence made a babel of sound? In every one of those dark, swaying,
sighing trees, there will be a very crowd of black, noisy, joyous birds, and
strange it is that there should be more poetry in all this noise and
clamour and bustle than in their sad sombreness, deeply as that speaks
to one. The poetry of life is beyond that of death, and when the rooks
have gone the dark plantation seems to want its soul. It is Cupid and
Psyche, but under dreary, northern skies. Every evening the black,
rushing wings come in love and seem to kiss the dark branches, every
morning they kiss and part, and, between whiles, the poor longing grove
stands lifeless, dreams and waits. But how different would it seem if the
rooks were a crowd of men—nice, cheery, jovial, picturesque, civilised
men! Thank heaven, they are a crowd of rooks!
I will now quote from my journal:
"Walking over some arable land that rises gently into a slight hill, my
attention is attracted by a number of rooks hanging in the air, just above
a small clump of elm-trees on its crest. They keep alternately rising and
falling as they circle over the trees, often perching amongst them, but
soon gliding upwards from them again. A very common action is for two
to hover, one above another, getting gradually quite close together, when
both sinking, one may almost say falling, rapidly, the upper pursues the
under one, striking at it—either in jest or earnest, but probably the former
—both with beak and claws. The downward plunge would end in a long
swoop, first to right or left, and then again upwards, during which the
two would become separated and mingled with the general troop. This
action, more or less defined and perfect, was continued again and again,
and there were generally one or more pairs of birds engaged in it. The
rest rose and fell, many together, and obviously enjoying each other's
society, but without any special conjunction of two or more in a joint
manœuvre. Their descents were often of a rushing nature, and
accompanied with such sudden twists and turns as, sometimes, seemed
to amount to a complete somersault in the air—though as to this I will
not be too certain. The whole seemed the outcome of pure enjoyment,
and seen in the clear blue sky of this fine bright October morning—the
last one of the month—had a charming effect.
"A fortnight later I happened to be near some woods to which rooks were
flying from all directions, to roost, as I thought then, but afterwards I
found it was only one of their halting places. They were in countless
numbers, one great troop after another flying up from far away over the
country. The air was full of their voices, which were of a great variety and
modulation, the ordinary harsh (though pleasant) 'caw' being perhaps the
least noticeable of all. Each troop flew high, and, on coming within a
certain distance of the wood—a fair-sized field away—they suddenly
began to swoop down upon it in long sweeping curves or slants, at the
same time uttering a very peculiar burring note, which, though much
deeper and essentially rook-like in tone, at once reminded me of the well-
known sound made by the nightjar. Imagine a rook trying to 'burr' or
'churr' like a nightjar, and doing it like a rook, and you have it. Whilst
making these long downward-slanting swoops the birds would often twist
and turn in the air in an astonishing manner, sometimes even, as it
seemed to me, turning right over as a peewit does, in fact, exhibiting
powers of flight far beyond what anyone would imagine rooks to possess,
who had only seen or noticed them on ordinary occasions.
"Whilst these birds sweep down into the trees others of them settle on
the adjoining meadow-land, but they do not descend upon it in the same
way, but more steadily, though still with many a twist and turn and
whirring, whizzing evolution. Neither do they utter the strange burring
note to which I have called attention, and which is a very striking sound.
Starlings are mingled with these latter birds, flying amongst them, yet in
their own bands, and alighting with them on the meadow, where they
continue to form an imperium in imperio. Both they and the rooks
descend at one point, in a black or brown patch, but soon spread out
over the whole meadow, from which they often rise up in a cloud, and,
after flying about over it for a little, come down upon it again. At last a
vast flock of starlings—numbering, I should think, many thousands—flies
up, and, being joined by all those that were on the field, the whole
descend upon the woods, through which they disseminate themselves.
Almost immediately afterwards, the rooks, as though taking the starlings
for their guide, rise too, and fly all together to the woods. Now comes a
troop of some eighty rooks, and, shortly afterwards, another much larger
one—two or three hundred at the least—all flying high, and going steadily
onwards in one uniform direction. They are all uttering a note which is
difficult to describe, and does not at all resemble the ordinary 'caw.' It
has more the character of a chirrup, loud in proportion to the size of the
bird, but still a chirrup—or chirruppy. There is great flexibility in the
sound, which has a curious rise at the end. It seems to express
satisfaction and enjoyable social feeling, and, if so, is very expressive.
One feels, indeed, that every note uttered by rooks is expressive, and if
one does not always quite know what it expresses that is one's own fault,
or, at any rate, not theirs.
"Twenty more now pass, then twenty-seven, and, finally, another large
body of some two to three hundred—all flying in the same direction. It is
the last flight, and, shortly afterwards, the loud harsh trumpeting of
pheasants is heard in all the woods and coverts around, as they prepare
to fly up into their own roosting trees. This dove-tailing of two
accustomed things in the daily life of rooks and pheasants I have often
noticed, but it must be mere coincidence, for pheasants vary in their
hours of retirement, whilst the leisurely homeward journeying of rooks,
with pauses longer or shorter at one place or another, occupies, in winter,
most of the afternoon.
"November 27th.—By the river, this afternoon, I noticed two great
assemblages of rooks down on the meadow-land, whilst others, in large
numbers, were flying en route homewards. Of these, two would often act
in the way I have before described—that is to say, whilst flying the one
just over the other with very little space between them, both would sink
suddenly and swiftly down, the upper following the under one, and both
keeping for some time the same relative position. But besides this, two
birds would often pursue each other downwards in a different way,
descending with wide sideway sweeps through the air, from one side to
another, after the manner of a parachute, the wings being all the while
outstretched and motionless. In either case the pursuit was never
persisted in for long, and obviously it was no more than a sport or an
evolution requiring the concurrence of two birds.
"Again, two will sweep along near together, at slightly different altitudes,
with the wings outspread in the same way—that is to say, not flapping.
Then first one and afterwards the other gives a sharp wriggling twist,
seeming to lose its balance for a moment, rights itself again, and
continues to sweep on as before. Then another wriggle, a further sweep,
and so on."
Since seeing the curious manner in which ravens roll over in the air—as
described by me—I have watched the aerial gambols, as one may almost
call them, of rooks more closely. There is a certain place, not far from
where I live, where these birds make an aerial pause in their homeward
flight; for, whilst many are to be seen settled in some lofty trees of a fine
open park, others sail round and round in wide circles and high in the air,
over a wide expanse of water in the midst of it. After wheeling thus for
some time, first one and then another will descend on spread wings, very
swiftly, and with all sorts of whizzes, half-turns or tumbles, and
parachute-like motions. When watched closely through the glasses,
however, it may be seen that, very often, these rushing descents have
their origin in an action, or, rather, an attempted action, very much like
that of the raven. The idea of the latter bird is to roll over, so as to be on
its back in the air, and, by closing its wings, it is able to achieve this
without, or with hardly, any drop from the elevation at which it has been
flying. The rooks seem to try to do this too, but instead of closing the
wings, they keep them spread, as open, or almost so, as before.
Consequently, instead of just rolling over, their turn or roll to either side
sends them skimming sideways, down through the air, like a kite—a paper
one, I mean. Peewits close the wings and roll over in much the same way
as does the raven, but this is generally either preceded, or followed, by a
tremendous drop through the air, with wings more or less extended, so
that the whole has quite a different effect.
"Of the two assemblies on the ground, one is in perpetual motion, birds
constantly rising—either singly, in twos or threes, or in small parties—
from where they were, flying a little way just above the heads of their
fellows, and re-settling amongst them again. Thus no individual bird, as it
seems to me, remains where it was for long, though those in the air, at
any given moment, form but a small minority, compared with the main
body on the ground.
"But the birds composing the other great assemblage keep their places,
or, if some few rise to change them, these are not enough to give
character to the whole, or even to attract attention. It is curious to see
two such great bodies of birds close to each other, and on the same
uniform pasture-land, yet behaving so differently, the one so still, the
other in such constant activity.
"About 4 P.M. a great number of rooks rise from some trees in a small
covert near by, and fly towards those on the ground. As they approach
the first great body—which is the lively one—the birds composing it rise
up, as with one accord, and fly, not to meet them, as one might have
expected, but in the same direction as they are flying. So nicely timed,
however, is the movement, that the rising body become, in a moment,
the vanguard of the now combined troop.
"All these birds then fly together to the other assembly, and whilst about
half of their number sweep down to reinforce it, the other half continue to
fly on. The flying rooks, however, are not joined by any of those on the
ground. How curious it is that, in the first instance, the one whole body of
birds does the same thing instantaneously, and as by a common impulse,
whilst in the second, half acts in one way, and half in another, each
appearing to have no doubt or hesitation as to what it ought to do! Again,
how different is the conduct of the two field-assemblages. One rises, as
with one thought, to join the flying birds. The other, as with one thought,
remains standing. Unless, in each case, some signal of command has
been given, then what a strange community of feeling in opposite
directions is here shown. Where is the individuality that one would
expect, and what is the power that binds all the units together?
"Are rooks led by an old and experienced bird?—which is, I believe, the
popular impression, as embodied in a famous line of Tennyson, for which
one feels inclined to fight. At first sight, the rising of a whole body of
rooks (or any other birds) simultaneously, either from the ground or a
tree, might seem to be most easily explained on the theory of one bird,
recognised as the chief of the band, having in some manner—either by a
cry or by its own flight—given a signal, which was instantly obeyed by the
rest. But how—in the case of rooks—can any one note be heard by all
amidst such a babel as there often is, and how can every bird in a band
of some hundreds (or even some scores) have its eyes constantly fixed on
some particular one amongst them, that ought, indeed, on ordinary
physical and mechanical principles, to be invisible to the greater number?
If, however, to meet this latter difficulty, we suppose that only a certain
number of birds, who are in close proximity to the leader, see and obey
the signal, and that these are followed by those nearest to them, and so
on till the whole are in motion, then two other difficulties arise, neither of
which seems easy to get over. For, in the first place, the birds do not, in
many cases, appear to rise in this manner, but, as in the instances here
given, simultaneously, or, at least, with a nearer approach to it than any
process of spreading, such as here supposed, would seem to admit of;
and secondly, it is difficult to understand how, if this were the case, any
bird—or, at least, any few birds—could fly up without putting all the
others in motion. Yet, as I have mentioned, birds in twos or threes, or in
small parties, were constantly rising and flying from one place to another
in the assemblage of which they formed a part, whilst the vast majority
remained where they were, on the ground. This fact offers an equal or a
still greater difficulty, if, dismissing the idea of there being a recognised
leader, we suppose that any bird may, for the moment, become one by
taking the initiative of flight, or otherwise. And even if we assume that
any of these explanations is the correct one, in the case of a whole body
of rooks taking sudden flight, or directing their flight to any particular
place, or with any special purpose, what are we to think when half, or a
certain number of the band does one thing, and the other half another,
each, apparently, with equal spontaneity? We are met here with the same
difficulties—and perhaps in a still higher degree—as in the case of the
flocks of small birds at the stacks in winter.
"If rooks follow and obey a leader, one might expect them to do so
habitually, at least in their more important matters. The flight out from
the roosting-trees in the morning, and the flight into them again at night
are—when it is not the breeding-season—the two daily 'events' of a rook's
life. Here, then, are two subjects for special observation.
"November 30th.—At 3 P.M. I take up my position on the edge of a little
fir-plantation, a short distance from where I watched yesterday and the
last few days. My object is to watch the flights of rooks as they pass, and
try to settle if each band has a recognised leader or not. Of course it is
obvious that no one bird can lead the various bands, for these come from
over a large tract of country, whilst even those that seem most to make
one general army, fly, often at considerable intervals of time, and quite
out of sight of each other.
"A good many are already flying in the accustomed direction, but singly,
or wide apart. Each bird seems to be entirely independent.
"The first band now approaches. One rook is much in advance for some
distance. He then deviates, and is passed by the greater number of the
others, who continue on their way without regard to him.
"Another great, irregular, straggling body in which I can discern no sign
whatever of leadership. Then comes another, more compact. A rook that
at first leads by a long interval is passed by first one and then another, so
that he becomes one of the general body.
"A large band, flying very high. Two birds fly nearly parallel, at some
distance ahead.
"Two large bands, also very high. In each, one bird is a good way ahead.
The apparent leader of the second band increases his distance, curves a
good deal out of the line originally pursued, nor do the others alter their
course in accordance.
"Two other bands. In each the leader theory seems untenable. The birds
have a broadly extended front, and fly at different elevations. There is
nothing that suggests concerted movement, but, on the contrary, great
irregularity.
"In another band the apparent leader swoops down to the ground, and,
whilst only half-a-dozen or so follow him, the main body proceeds on its
way.
"Hitherto there has been a good deal of the familiar cawing noise, but,
now, a number of birds fly joyously up, hang floating in the air, make
twists and tumbles, perform antics and evolutions, and descend upon the
ground with wide parachute-like swoops from side to side, the wings
outspread and without a flap. I am first made aware of their approach by
the complete change of note. It is now the flexible, croodling, upturned
note—rising at the end, I mean—that I know not how to describe, totally
different from the 'caw,' nor do I hear a 'caw' from any of these
descending birds. It is the note of joy and sport, of joyous sport in the air,
of antics there as they sweep joyously down through it, that I now hear.
The birds that caw are flying steadily and soberly by. The 'caw' is the
steady jog-trot note of the day's daily toil and business—'Jog on, jog on,
the footpath way.'
"Another great band, of such length and straggling formation that the
birds in the latter part of it could not possibly see the leader if there were
one—or indeed, I should think, the vanguard at all. The first bird is
passed by two others, then passes one of these again, and remains the
second as long as I can see them.
"Another long flight that seems leaderless. With the 'caw' comes a note
like 'chug-a, chug-a, chug-a' (but the u more as in Spanish), and others
that I cannot transcribe. This flight goes on almost continuously—I mean
without a distinct gap dividing it from another band—for about ten
minutes, when another great multitude appears, flying at an immense
height and all abreast, as it were—that is to say, a hundred or so in a
long line of only a few birds deep. This, perhaps, would be the formation
best adapted for observing and following one bird that flew well in front,
but I can see no such one. All these birds are sailing calmly and serenely
along, giving only now and again an occasional stroke or two with the
wings. Now comes a further great assembly, in loose order, all flying in
the same direction. A characteristic of these large flights of rooks is that
their van will often pause in the air and then wheel back, circling out to
either side. The rearguard is thus checked in its advance, the birds of
either section streaming through each other, till the whole body, after
circling and hanging in the air for a little, like a black eddying snowstorm
(all at a great height), wend on again in the same direction, towards their
distant roosting-place. With the air full of the voice of the birds, there is
no caw—only the flexible, croodling, chirruppy note that has a good deal
of music in it, as well as of expression. This note, I think, is what I have
put down as 'chug-a, chug-a, chug-a.'
"There is now a continuous straggling stream, forming ever so many little
troops. The first bird of one troop tends to become the last of the one
preceding it, and the last one the leader of the troop following. Then
come numbers, flying in a very irregular and widely disseminated
formation, yet together in a certain sense. There is much of rising and
sinking and again floating upwards, of twists and twirls and sudden,
dashing swoops downwards, from side to side, like the car of a falling
balloon; two birds often pursuing each other in this way.
"And now come two great bands, one flying all abreast, as before
described, the other forming a great, irregular, quasi-circular rook-storm.
Leadership in the latter case would be an impossibility; in the former I
see no sign of it. All these birds, though at a fair height, are flapping
steadily along in the usual prosaical manner; through them, and far above
—at a very great height indeed, the highest I have yet seen, and far
beyond anything I should have imagined—I see another band gliding
smoothly, majestically on, with scarce an occasional stroke of the eagle-
spread pinions. The one black band of birds seen through the others, far,
far above them, has a curious, an inspiring effect."
Rooks, when in continued progress, either fly with a constant, steady
flapping of the wings, in a somewhat laboured way, though often fairly
fast, or they sail along with wings outspread, and flapping only from time
to time—this last, however, only when they are at a considerable height.
A crowd of rooks, indeed, in the higher regions of air present a very
different appearance to what they do when they fly about the fields, even
though at a fair height above the trees; their powers of flight in each case
seem of a very different kind. They can also soar to some extent, rising
higher and higher on outspread wings as they sweep round and round in
irregular circles—like gulls, but far less perfectly, and they have to flap the
wings more often. Add to this their downward-rushing swoops, their
twists, turns, tumbles, zig-zaggings, and all manner of erratic aerial
evolutions, and it must be conceded that the powers of flight which they
possess are beyond those with which we generally associate them in our
mind.
Seen thus, trooping homewards, in all their many moods and veins,
their flight, combined with their multitude, is full of effects. To-day their
widely extended bands were often, like so many black snowstorms filling
a great part of the sky. But at no time did I see anything resembling
leadership. "The many wintered crow that leads the clanging rookery
home" is—a lovely line. On no other occasion could I make out that rooks
obeyed or followed any recognised leader, and I came to a similar
negative conclusion in regard to the question of their employment of
sentinels. It is asserted in various works—for instance, in the latest
edition of Chambers's "Encyclopedia"—that they do post sentinels. I will
give two instances of their not doing so—as I concluded—and my
experience was the same on other occasions, which I did not think it
worth while to note.
"December 22nd.—To-day, I saw a number of rooks blackening a heap of
straw by a stack, whilst some were on the stack itself. Many were sitting
in some elms near about, but they did not appear to me to be acting the
part of sentinels. When I tried to get up to the hedge in order to watch
the rooks at the stack, through it, they flew off, a good deal later than
their friends in the trees must have seen me, and not till I was quite near.
If these had really been sentinels, they should have warned the rest,
either the instant they saw me, or at any rate, when I was obviously
approaching, but this they did not do. They were, therefore, either not
sentinels or inefficient ones." The second case, however, is more
conclusive.
"January 8th.—To-day, on my way down to the roosting-place, I pass a
number of rooks feeding in a field, and not far from the road. They are all
more or less together, there are no outposts, though of course there is, of
necessity, an outer edge to the flock. But neither on the hedge or in any
of the trees near, are there any birds to be seen. On the other side of the
field, however, and a very considerable way off, a few are sitting in some
trees. It hardly seems possible that these can act the part of sentinels at
such a distance, and even if they were much nearer, the feeding rooks
would have either to be looking at them, to see when they flew, or else,
the alarm must be given by a very loud warning note. Bearing this in
mind, I alight from my cycle, and walk along the road. The rooks, without
any dependence on sentinels far or near, note the fact, bear a wary eye,
but continue feeding. I then stop—always an alarming measure with
birds. The feeding rooks fly off to a safer distance, the ones in the trees
remain there as silent as ever, nor is there any special note uttered by any
one bird of the flock, nor anything else whatever to suggest that any
particular bird or birds is acting the part of sentinel." There is certainly no
sentinel in this case, and in matters directly affecting their safety one
might suppose that rooks, as well as other birds and beasts, would act in
a uniform manner. This, however, we can clearly see, that when there
happen to be trees, near where they are feeding, some of them will
usually, and quite naturally, be perched in them, and average human
observation and inference may have done the rest.
Rooks, I am inclined to think, are not birds that give their conscience into
keeping. Each one of them is his own sentinel.
CHAPTER XI
Watching Rooks—continued
Continuing my journal, I will now give extracts which illustrate, principally,
the return home of the rooks at night and their flying forth in the morning
—those two aspects of their daily winter life which are the most full,
perhaps, both of interest and of poetry.
"December 9th.—This afternoon at about 3.30 I find vast numbers of
rooks gathered together on a wide sweep of land, close to their roosting-
place.
"Even now—and they are being constantly reinforced—they must amount
to very many thousands, and cover several acres, in some parts standing
thickly together, in others being more spread out. There is an
extraordinary babble of sound, a chattering note and the flexible,
croodling one being conspicuous. Combats are frequent—any two birds
seem ready to enter into one at any moment—and they commence either,
apparently, by sudden mutual desire, or else by one bird fixing a quarrel
on another, which he does by walking aggressively up to him and daring
him, so to speak. In fighting they stand front to front, and then spring up
at each other—like pheasants, but grappling and pecking in the air as do
blackbirds and small birds generally. Sometimes one bird will be worsted
in the tussle, and you instantly see it on its back, striking up with claws
and beak at the other, who now bestrides it. It is easier to see this result
than to be sure as to the process by which it is arrived at—whether, for
instance, the overmatched bird falls, willy-nilly, on its back, or purposely
throws itself into that position, so as to strike up like a hawk or owl. I
think that this last may sometimes be the case, from the very accustomed
way in which rooks fight under such circumstances; but, no doubt, it
would only be done as a last resource. The rooks, however, do not seem
vindictive, and their quarrels, though spirited, are usually soon over. They
may end either by the weaker or the less acharné bird retiring, in which
case the pursuit is not very sustained or vigorous, or else by both birds,
after a short and not very rancorous bout, pausing, appearing to wonder
what they could have been thinking about, and so walking away with
mutual indifference, real or assumed. Often one bird will decline the
combat, and in this case, as far as I can see, it is not molested by the
challenger, however bullying and aggressive this one's manner may have
been. A rook coming up to another with the curious sideway swing of the
body and a general manner which seems to indicate that he thinks
himself the stronger of the two, looks a true bully.
"One rook has just found something, and, whilst standing with it in his
bill, another comes forward to dispute it with him, but the attack is half-
hearted, and seems more like a mere matter of form. Afterwards, when
the same bird has the morsel on the ground in good pick-axeing position,
a second rook advances upon him with a quick, sideway hop, looking
cunning, sardonic, diabolic, and much for which words seem totally
wanting. But this attack, though swift and vigorous, is not more
successful than the former one. The lucky rook gets off with his booty,
and has soon swallowed it. Amongst rooks, the finding of anything by any
one of them is a recognised cause of attack by any other. This is taken as
a matter of course by the bird attacked, and if he holds (and swallows)
his own, which, as he has a clear advantage, he generally does, no
resentment is manifested by him—there is not even a slight coolness after
the incident is over. If, however, the attack should be successful, then it is
very different. The annoyance is too great for the robbed bird, and he
becomes very warm indeed. He makes persistent violent rushes after the
robber, is most pertinacious, and clearly shows that kind of exasperation
which would be felt by a man under similar circumstances. It seems not
so much his own loss, as the success and triumphant bearing of the other
bird, that upsets him. He has failed where he ought to have been
successful, and of this he seems conscious.
"When one rook makes his spring into the air at another, this one will
sometimes duck down instead of also springing. The springer, then, like
'vaulting ambition,' 'o'erleaps himself and falls on the other side.' I have
just seen this. The rook that bobbed seemed to have scored a point, and
to know it, which the other one confessed shame-facedly—no,
indescribably, a rook cannot look shame-faced. The advantage was not
followed up by the successful bird, but the combat ceased, I think, in
consequence.
"I now notice a hare a little on the outside of the phalanx of rooks, at the
part of it nearest to myself. All at once he makes a little run towards them
as if charging them, and sits down, making one of their first line, and
almost, as it seems, touching two or three. After sitting here for some
while the hare makes another little run, this time right in amongst the
rooks, several of which he puts up as though on purpose—each of the
birds giving a little jump into the air with raised wings, and coming down
again. He then sits down as before, but this time all amongst them. This
he repeats several times, making little erratic gallops through the black
crowd, in curves to one side and another, and appearing to enjoy the fun
of causing rook after rook to jump up from the ground. Half-a-dozen
times he runs right at a rook that he might easily have avoided, and sits
down amongst them two or three times, again. At last, in a final gallop,
he pierces the squadron and continues on, over the land. This certainly
appeared to me to show a sense of fun, if not of humour, on the hare's
part, and as—with a few noted exceptions—it is the rarest thing to see
one species of animal take any notice of another, I was proportionately
interested.
"It is now half-past four, and for about an hour the great assemblage has
been increased by a perpetual stream of rooks, that sail up and descend
into it with joyous wheels and sweeps. For some time, too, flocks of the
birds have been flying from the ground into trees near. They fly by relays,
and from the farthest part of the troop—that is to say, from that part
which is farthest distant from the woods where they are to roost. First
one band of birds and then another rises from the outer extremity, flies
over the rest, ascending gradually, and wings its way to the trees. By
these successive flights the assemblage is a good deal shrunk, and does
not cover nearly so much ground, when the remainder—still an enormous
number—rise like a black snowdrift whirled by the wind into the air, and
circle in a dark cloud, now hardly visible in the darkening sky, above the
roosting-trees, with a wonderful babel of cries and noise of wings.
"At 4.40 this deep musical sound of innumerable crying, cawing,
clamouring throats is still continuing, and once, I think, the birds rise from
the trees into which they have sunk, and circle round them again. Now
they are in the trees once more, but the lovely cawing murmur—the hum,
as though rooks were rooky bees—still goes on.
"4.47.—It is sinking now. Much more subdued and slumberous, deliciously
soothing, a rook lullaby.
"December 11th.—A stern winter's day, the earth lightly snow-covered,
but bright and fine in the morning. At 3 P.M. I am where the rooks roost,
a plantation of fir-trees—larches—dark, gloomy and sombre, with a path,
piercing them like a shaft of light, over-arched with their boughs, silvered
now with light snow-wreaths. Just in this gloomy patch they sleep, but
with a light belt of smaller firs opposite, or with adjoining woods of oak
and beech they will have nothing to do, leaving these latter to the wood-
pigeons.
When the rooks sweep down, thus, into their roosting-trees they
frequently do so with a peculiar whirring or whizzing noise of the wings,
but although this sound is in perfect consonance with the motion which it
accompanies—insomuch that one has to use the same words to describe
each—yet it does not seem to be produced by it. At least, it bears no
relation to the height from which the birds swoop, nor—as would seem to
follow from this—with the impetus of the descent. It may be a matter of
impetus, but to me it has often seemed more as though the sound gave
the idea of impetus, or added to it, and that the sweeps were,
sometimes, just as impetuous, or even more so, when made without it.
As I observed, the birds flew to their trees at a very moderate height—not
very much, indeed, above the trees themselves—and, whilst many made
the whizzing sound, the great majority swooped down without it. It
seems, therefore, to be a special sound produced by the rooks at
pleasure, and always accompanying an excited frame of mind. First one
bird and then another gets excited, and dashes suddenly down with the
whirring or whizzing noise, so that, as the sound is not vocal, and is only
heard upon such occasions, it has all the appearance of being caused by
the quick, sudden motions of the wings. But it is possible that some
particular way of holding the quill-feathers of the wing or even tail is
required to produce it, in combination with the general movements, and
this would account for its being sometimes heard and sometimes not
heard, when these latter are identical.[21] The curious burring note is
likewise, but far less frequently, an accompaniment of these wild excited
sweepings, and this is most often the case when they are from a
considerable height. Here, again, the note bears a clear relation to the
bird's mental state, so that it would appear that the degrees of
pleasurable excitement cannot be estimated by the motions alone. The
"burr," in my opinion, when well and loudly uttered—for here, again, there
is much variety—marks the maximum of a rook's content, at any rate in a
certain direction.
[21] With regard to the above, however, I am now no longer so sure.
Je m'en doute. When the rooks descend from a height, the sound
made is often most remarkable, being that of a mighty rushing wind
filling the air.
"But they sank peacefully down, and all of evil seemed to go, with their
sweet, joyous, innocent, and well-loved voices."
Here is one last picture, and I would point out that, on all these three
occasions, when the rooks slept in changed quarters, at a later time of
the year, the way in which they approached or entered the trees, and the
height at which they flew, varied, in a greater or less degree, from what it
had been before.
"March 11th.—At 6.20 a small band of rooks comes flapping along in the
usual jog-trot way, and enters the plantation. Some five minutes
afterwards a very large number sail up, flying at a great height, and
gather like a storm-cloud above it. They hang over it, then drift, circling, a
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com