Meteor JS for beginners
Introduction to meteor js:
What’s inside?
- Meteor is a full-stack JavaScript platform for developing modern web and mobile applications.
- It' is open source.
- It's released in 2012 by the meteor development group
- It's is written using node js.
- By default MongoDB as the default database for any application.
- Mongo DB (For Database)
- Node js (For application running(server).
- Lots of packages (To reduce the code and time)
- For install of packages go to http://atmospherejs.com/ it's is a repository for meteor packages.
- Installation is as simple as it can be Build reactive apps in no time.
- Build mobile apps in no time
- Deployment using 1 command.
- After changes in source code no need to build and deploy the application .meteor by default build and deploy the application into the server.
Installation (windows/ Linux)
Installation is very simple, using one command to install the whole setup.
- For Linux users: curl https://install.meteor.com/ | sh
- For Windows users: https://install.meteor.com/windows.
Application Structure
- lib
- client
- server
- public
Components
Templates:Templates are used to create a connection between our interface and our JavaScript code.
Sample snippet:
<body>
{{> loginButtons}}
</body>
<template name="leaderboard">
<h1>Welcome to Meteor!</h1>
</template>
helpers: a helper function is a regular JavaScript function that’s attached to a template and allows us to execute code from within an interface.
Sample snippet:
Template.leaderboard.helper({
'function reference name' : function(){
return "janardhan randhi"
}});
Each block: It iterates the elements (like for loop in java).
Sample snippet:
{{#each player}}
{{Filed name}}
{{/each}}
Events: Events allow us to trigger the execution of code when a user clicks on a button.
Sample snippet:
Template.leaderboard.events({
'click': function(){
// code goes here
}
});
Sessions: sessions allow us to store small pieces of data that is not saved to the database.
To create a Session use the below statement
Session.set('Reference name ', 'value');
To get the session use the below statement
Session.get('Reference name');
Methods: Methods are blocks of code that are executed on the server after being triggered by the client.
Sample snippet:
Meteor.methods({
'MethodRefName': function(){
console.log("Hello world");
}
});
To call a method :Meteor.call('MethodRefName');
Sample snippet:
<body>
{{> loginButtons}}
</body>
<template name="leaderboard">
<h1>Welcome to Meteor!</h1>
</template>
helpers: a helper function is a regular JavaScript function that’s attached to a template and allows us to execute code from within an interface.
Sample snippet:
Template.leaderboard.helper({
'function reference name' : function(){
return "janardhan randhi"
}});
Each block: It iterates the elements (like for loop in java).
Sample snippet:
{{#each player}}
{{Filed name}}
{{/each}}
Events: Events allow us to trigger the execution of code when a user clicks on a button.
Sample snippet:
Template.leaderboard.events({
'click': function(){
// code goes here
}
});
Sessions: sessions allow us to store small pieces of data that is not saved to the database.
To create a Session use the below statement
Session.set('Reference name ', 'value');
To get the session use the below statement
Session.get('Reference name');
Methods: Methods are blocks of code that are executed on the server after being triggered by the client.
Sample snippet:
Meteor.methods({
'MethodRefName': function(){
console.log("Hello world");
}
});
To call a method :Meteor.call('MethodRefName');
Available packages
- login provider: These packages make it extremely easy to add a back-end for an accounts system to an application.
- Accounts-password: This package creates the back-end for an accounts system that relies on an email and password for registration and logging in.Accounts-UI : To instantly add the front-end of an accounts system to a project. etc....
Useful Commands
- For creating a project: meteor create project-name
- For adding packages: meteor add package-name
- For removing packages: meteor remove package-name
- For running application: meteor run or meteor
- For reset the database: meteor reset
- For adding platform:meteor add-platform name
- For building the application: meteor build platform-name
Deployment
- Create a server on a site like DigitalOcean.
- Install the required software on that server.
- Configure the install of that software.
- Upload the project files to the server.
Reference links
0 Response to "Meteor JS for beginners"
Post a Comment