Monday, September 4, 2017

Best Meteor Performance Techniques



  1. Prevent publishing too much of data 

You may have heard this one already. It’s one of the first performance optimizations a Meteor developer tends to discover. But given the performance cost from tracking a large amount of real-time data, it’s definitely worth a reminder.With Meteor, the server maintains a copy of every client’s version of the database. So, the more clients connected, the more copies it has to track. Now, having many clients means your app is being used and appreciated. So, you probably don’t want to reduce the number of clients. But you should reduce the potential performance hit by minimizing the amount of data needed by each client.We can do this via our Publish functions. The Publish functions make real-time data available for each client to use. So, if you can implement the Publish function to send only what is absolutely needed, the amount of data is reduced.To do this, you must first understand why every part of the data set is needed and how they will be used. Is the data associated with a certain user? If so, is only that user’s data needed? Will all the fields be required for display or processing on the client? Or, just a certain subset? Will all records be displayed at the same time? Or, will the user “page through” the data set? Asking questions like these will provide ideas on how to start narrowing your publication.Let’s say you’re developing a chat app. If only a list of authors participating in a certain channel are needed, then you can use field filtering in your publish function to send back only their names:

Meteor.publish(“channelParticipants”, function(channelId) {
       return  Messages.find({channelId: channelId}, {fields: {authorName: 1}});
});

                                       

Sunday, January 29, 2017

MeteorJs


  • How to install MeteorJs for Windows?

                                         Download the meteor setup(.exe) file from the official meteor website and run it and install it on your computer.


  • To create your first MeteorJs project run the below command in command prompt

"meteor create myFirstApp"


  • Go to the root folder myFirstApp type below command

"meteor"


  • Now it will create your meteor application.Enter below url in your web browser.

"http://localhost:3000/"
this is the default url.If you want to run your project in another port use the below command
"meteor run --port portnumber"
you can use another port instead of 3000 port using above command(eg- meteor run --port 3030)

click here to download an example
meteor_command