Shalvin Interests

Sunday, October 28, 2018

React Native

React Native is a technology from Facebook to create native Android and iPhone applications. It uses the familiar JavaScript language and JSX syntax.

The easiest way to get started with React Native is to install Expo app in you mobile, going to https://snack.expo.io site and start coding. Setting up a development environment for React Native is a bit involved. We will take it up later.




>npm i -g create-react-native-app


>npm run android







Saturday, October 27, 2018

Node JS

Node is a JavaScript based Web Framework. Node's Non-blocking architecture makes it a very popular framework. V8 is the Virtual Machine of Node.


Node REPL
Once Node is installed, Node REPL can be invoked by typing node in the command prompt.



Typing tab tab in the prompt  displays  all Global command.

If you type a module name followed by tab tab it will display all the options pertaining to it.





Creating Http Server


const http = require('http');

const server = http.createServer((req, res) => {
  res.end('Hello World\n');
});

server.listen(4242, () => {
  console.log('Server is running...');
});


setTimeOut

setTimeout(
  () => {
    console.log('Hello after 4 seconds');
  },
  4 * 1000
);

Functions and Arguments
const consulting = who => {
  console.log(who + ' consulting');
};

setTimeout(consulting, 2 * 1000, 'Shalvin');

Thursday, October 25, 2018

Express JS

Hello Express


var express = require('express');

var app = express();

app.get('/', function (req, res) {
    res.send('Hello from Library app');
})

app.listen(3000, function () {
    console.log('listening ');
})


sendFile

In the previous example we just displayed some text. Now we are going to add an html file into the views folder and name it index.html.

var express = require('express');
var path = require('path');

var app = express();

app.get('/', function(req, res){
    res.sendFile(path.join(__dirname, 'views', 'index.html'));
})

app.listen(3000, function(){
    console.log('listening');
})