Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Meteor Design Patterns
Meteor Design Patterns

Meteor Design Patterns: Accelerate your code writing skills with over twenty programming patterns that will make your code easier to maintain and scale

eBook
$26.98 $29.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Meteor Design Patterns

Chapter 2. Publish and Subscribe Patterns

This is by far the most important chapter in this book. The way we control our publishers and subscribers is going to define how quickly our application responds in production. Publishers and subscribers are the link between our database and the client. The server uses publishers to publish information to the client, while the client requests information from the publishers by subscribing to them. This is all managed via the Meteor.publish and Meteor.subscribe functions. We should be able to produce the data that the client wants to see with two objectives in mind:

  • Reduce stress from the server
  • Send only the information that the client needs

This chapter will teach you the different patterns that you can use to attain these objectives for every template that you build. Here is an overview of the topics we will cover to understand these patterns:

  • Template-level subscriptions
  • Database relationships
  • Publishing with relations
  • Aggregation publishers...

Template-level subscriptions

This pattern attaches the Meteor.subscribe functions to templates. The key advantage of subscribing from the template is the ability to isolate the template and know that it still works when it is rendered.

Many Meteor developers attach their subscription methods to their routes. This means that the template will only render with the correct data at that particular route.

With this pattern, we will be able to reuse templates anywhere without worrying about data.

Setting up products for the online shop

Let's start by setting up a Products collection in MongoDB for our online_shop project. In Chapter 1, Getting Started with Meteor we learned that we need to place this definition under the /globals/lib/collections directory:

# /globals/lib/collections/products/products.coffee
@Products = new Mongo.Collection "products"

# fields:
#  name
#  description
#  sku

It's important to note that we are adding @ at the beginning of the Products variable. This...

Database relationships

Our collections will always be related in one way or another to other collections in our database. This topic is going to examine the three different types of relationships you should be thinking about when you are designing your database.

The shape that our database will take ultimately defines what our publishers are going to look like. If your data is all mashed up in just one or two different collections, you will very quickly find yourself struggling to filter data. If your data is spread too far between collections, the code will become difficult to maintain in the long run. So what is the solution to this problem?

The solution to database relationships is to understand how the data is going to be used in the client, how often it is going to be modified, and how large the set can be.

Let's build out the rest of our collections to get a notion of what good relationships look like.

One to one

A one to one database relationship describes how one MongoDB document...

Left arrow icon Right arrow icon
Download code icon Download Code

Description

With the increasing interest in NodeJS web applications, a new framework, Meteor, has joined the ranks to simplify developer workflows. Meteor is one of the few open source frameworks that has received funding since its early development stages. It builds on ideas from existing frameworks and libraries, offering developers an easy way to develop a prototype app. At the same time, it gives them the tools and flexibility to build a fully fledged production app. Meteor is the weapon of choice for start-ups in today’s world. Meteor Design Patterns cuts through the jargon that most websites play with and gets to the point with simple solutions that will boost your development skills. We start off with a refresher on the basics of JavaScript programming such as templates, CoffeeScript, the Event Loop, and the Merge Box, amongst others. You then learn how to map real-world data and optimize the data’s publishers to output data with the least amount of work done by the server with some subscribe and publish patterns. Next, using front-end patterns, you will learn how to create maintainable and trackable forms, and make our site crawlable by any search engine. Following this, you will see how to optimize and secure the web application and maintain applications without breaking other features. Finally, you will learn how to deploy a secure production-ready application while learning to set up modulus, compose with Oplog tracking and SSL certificates, as well as error tracking with Kadira. Throughout the book, you will put your skills to practice and build an online shop from scratch. By the end of the book, you will have built a feature-rich online shop.

Who is this book for?

This book is for developers who have already had an introductory course with Meteor. Basic knowledge of web development is recommended.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 21, 2015
Length: 184 pages
Edition : 1st
Language : English
ISBN-13 : 9781783987627
Vendor :
Meteor Development Group
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Oct 21, 2015
Length: 184 pages
Edition : 1st
Language : English
ISBN-13 : 9781783987627
Vendor :
Meteor Development Group
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 109.97
Building Single-page Web Apps with Meteor
$26.99
Meteor Cookbook
$43.99
Meteor Design Patterns
$38.99
Total $ 109.97 Stars icon

Table of Contents

7 Chapters
1. Getting Started with Meteor Chevron down icon Chevron up icon
2. Publish and Subscribe Patterns Chevron down icon Chevron up icon
3. Front-end Patterns Chevron down icon Chevron up icon
4. Application Patterns Chevron down icon Chevron up icon
5. Testing Patterns Chevron down icon Chevron up icon
6. Deployment Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(6 Ratings)
5 star 50%
4 star 33.3%
3 star 0%
2 star 16.7%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




rsundar Nov 19, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A very useful resource to take your meteor skills to the next level. Shows you how you can deploy your meteor applications in a production setting and use Kadira to enhance it's performance. All in all definitely recommended for someone who has a good grasp on the basics of the meteor framework.
Amazon Verified review Amazon
James Coles Oct 28, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I had this book on preorder the moment I saw it on Amazon. It arrived and I read it within the day. I've got 4 books on Meteor in total and this one is by far the best one I have read so far. It's the story told from start to end. It's not a lose collection of recipes it as the cookbooks and it's not a half hearted approach to explain a few features or modules as other books on the market. This is a reference and a milestone book for meteor. If you want to get serious about this framework. Get this book.If I have one concern it is that the book is using coffeescript, stylus and jade, but it's simple enough to translate this to javascript, scss and html templates when needed.
Amazon Verified review Amazon
Lars Lemos Dec 04, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I come from a Java EE background so was looking for a fast paced recipes book.Found exactly what I needed.This book contains this most fundamentals instructions from how to set up your development environment from scratch to the introduction to the Front-end patterns and Application patterns, it also include testing Patterns and the most important how to deploy our app to the cloud services.Although being a small book, the author was able to compact all the necessary information for the best understanding of the reader.I advice to read this book along with some other reference book or documentation to make the most out of the content that the patterns describe.What fascinated me more in this book was the fact that I was not expecting to find instruction on how to put my app in production since by the name "Meteor Design Patterns", so you get more than you expected.The book is worth reading and future reference.
Amazon Verified review Amazon
Kevin Nicholas Casault Nov 24, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Let me start by saying I am not a Meteor expert just someone in the process of learning Meteor. Also just to be clear when you read design patterns in the title think reusable solutions or good practices not along the concept of the Gang of 4 design patterns. I feel like the advice in the beginning of the book about using JavaScript (Coffee) and CSS (Stylus) preprocessors and HTML (Jade) template engines could probably be used with any modern JavaScript framework. Probably good advice in general. From Chapter 2 on the book is much more Meteor specific in the solutions it presents. The different types of variables available to Meteor applications was a good discussion for example. As someone learning Meteor, many of the patterns were very helpful as I think about building Meteor applications and what needs to be done to make a Meteor application search engine friendly.The product order/shopping cart example used through out the book is helpful and easy to understand as the features are added to it through out the book.The book has been a good learning tool and I can see it being a good tool to refer to in the future as well. The design patterns presented should be helpful even as Meteor matures and changes of time.There are also many atmosphere packages discussed and recommended in the book to help solve specific problem this is a nice add because searching through packages can be a time consuming.
Amazon Verified review Amazon
eskadah Nov 20, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
At the time of writing, this book is one of the few advanced level books on Meteor that are available on the market. This book guides the reader on a number of best practices for real world meteor development.Furthermore, the author of the book has a number of open source meteor packages that I have found very useful in my own work. So he definitely knows what he is talking about. For instance, the author does a good jobexplaining the importance of reactive joins in Meteor projects, the author illustrates the problem from a UI /UX perspective but ultimately breaks down the technical DDP aspects of the problem and mostimportantly provides practical solutions to implementing reactive joins in Meteor. I am giving this book 4 stars for a number of reasons. Given the fact that the code samples are in CoffeeScript,the editing could be better. Its a bit of a chore to read and understand a code sample given the liberal use of tabs, lack of commas and absent parentheses. This point brings me to my second gripe with the book.The book is very opinionated. The author tries to mitigate this in the first chapter but one chapter to introduce Coffeescript, Jade and Stylus is not enough. Readers that are not already versed in these technologies will not be able to gain much from this book.All in all, its a very good intermediate/advanced level book on Meteor. Beginners to the Meteor framework should probably look elsewhere for an introduction but they should definitely come back once they are looking for more advanced knowledge
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.