Posts

Working with Observable and BehaviorSubject in Angular

Image
Observable: Observable opens a continuous communication channel which can emit multiple values of data over a  period of time. Observable will not be invoked until you subscribe to it. The subscribe method has three call back functions as parameters. When ever the data is available then first callback function will be invoked. When there is an error then second callback method will be invoked. Once you call complete() from observer then third callback function will be invoked. Here is an example. Step #1:  First import necessary libraries. import { Observable } from ' rxjs ' ;   Step #2:  Declare a variable as Observable and  define Observable.  data:Observable<number>;    ngOnInit(){         this .data =  new  Observable(observer=>{          observer.next(1);          ...

How to create multi project templates in Visual Studio 2017?

Image
Project templates are very useful and helps developers to make initial set up ready. For example, if you are working on a web project which needs other layers like Data, Entity and Service..etc. You may create each of them as a library projects and refer among them as you need. But when you start with another web project you may need to do all this process again. Because Visual Studio by default does not support multi project templates. In this article I am going to explain how to create multi project templates and make them re-usable. In this example I am using .Netcore Web Api project. Step #1:   Create a .Netcore WebApi Project using Visual Studio. Select the Api project as shown below.  Step #2:   Create Data, Entity and Service layers as library projects.  Create Entity and Service layers in the same way. Once you create all the layers the Solution explorer should look like below.  Step #3:   Now we need to add re...

Build WebServer With Node.js

Image
Node.js is a javascript server side framework. It means we can execute javascript code at the serverside and aslo all client requests will be processed with javascript. It is asynchronous. It means when you are doing server side i/o related operations still parallely it can handle other requests. Hence it can handle heavy load traffic.  Prerequisites: 1. Download and Install Node.js from here . 2. Any Editor like Notepad/Notepad++/Visual Studio Code. How to Create a WebServer: Step #1: Write the below code into a notepad and save it with some name like index.js var  http = require( 'http' );      http.createServer( function  (req, res) {       res.writeHead(200, { 'Content-Type' :  'text/plain' });       res.end( 'Hello World!' );   }).listen(5000);   In the above code you can see req and res parameters. The req object c...

Dynamic Linq: Construct linq queries on fly in C#

Linq is a great feature of .net framework which makes the queries more readable and simplifies the queries. Sometimes we may need to construct the queries dynamically.  Dynamic linq supports to construct queries on fly. This is mainly helpful when you want to construct logic from UI or pass queries from XML or any configuration file. The below is the test data used throughout this article. Download Dynamic linq code Test Data: List<Employee> employees =  new  List<Employee>();      Employee employee1 =  new  Employee {Name =  "Sampath" , Age = 25, Salary = 5000M, Id = 1};   Employee employee2 =  new  Employee { Name =  "Kumar" , Age = 27, Salary = 10000M, Id = 2 };   Employee employee3 =  new  Employee {...