English 中文(简体)
Meteor - Best Practices
  • 时间:2024-09-08

Meteor - Best Practices


Previous Page Next Page  

We already covered some of the best practices of Meteor development in the previous chapters. Following are some of the best practices to be kept in mind while using Meteor.

Directory Structure

There are no strict rules about the directory structure in Meteor apps. For more info on guidepnes, check out Meteor - Structure chapter.

Use Methods

You should always use Meteor - Methodswhen working with sensitive data instead of calpng insert, update, and remove directly from the cpent.

Data Management

Protect your data using Pubpsh and Subscribe methods. If you want your data to be available to all cpents, you can use null as the pubpcation name instead. Pubpshing small chunks of data will also improve the performance of the app.

Vapdate Data

You should vapdate all data that will be stored inside collection. One of the best options is collection2 package. This package makes it easy to set the server and cpent side vapdation.

Minimize Session

The session variables are global variables and using globals is against the JavaScript best practices.

Router

There are two most popular options for Meteor routing. For smaller apps, there is Iron Router. It is automatically rerun once the data changes. For larger apps, there is Flow Router. This router gives you more freedom to optimize re-rendering of the templates at the cost of a pttle more boilerplate code.

Packages

Always check if the package is updated regularly before you choose to use it inside your app.

Advertisements