<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	 xmlns:media="http://search.yahoo.com/mrss/" >

<channel>
	<title>JavaScript &#8211; Nearshore Software Development Company &#8211; IT Outsourcing Services</title>
	<atom:link href="https://nearshore-it.eu/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>https://nearshore-it.eu</link>
	<description>We are Nearshore Software Development Company with 14years of experience in delivering a large scale IT projects in the areas of PHP, JAVA, .NET, BI and MDM.</description>
	<lastBuildDate>Wed, 21 Aug 2024 14:01:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://nearshore-it.eu/wp-content/uploads/2023/01/cropped-inetum-favicon-300x300-1-32x32.png</url>
	<title>JavaScript &#8211; Nearshore Software Development Company &#8211; IT Outsourcing Services</title>
	<link>https://nearshore-it.eu</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Gulp vs Webpack. What is better: Using Webpack or Gulp.js?</title>
		<link>https://nearshore-it.eu/technologies/gulp-vs-webpack-what-is-better/</link>
					<comments>https://nearshore-it.eu/technologies/gulp-vs-webpack-what-is-better/#respond</comments>
		
		<dc:creator><![CDATA[Maciej Woźnica]]></dc:creator>
		<pubDate>Thu, 07 Sep 2023 03:31:00 +0000</pubDate>
				<category><![CDATA[Technologies]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://nearshore-it.eu/?p=25205</guid>

					<description><![CDATA[Webpack vs Gulp? Understanding differences these tools and similarities will undoubtedly help us make the right decision. Read on to make job easier and increase level of productivity.]]></description>
										<content:encoded><![CDATA[
<div class="table-of-contents">
    <p class="title"></p>
    <ol>
                    <li><a href="#SCSS-vs-CSS-–-the-basics">1.  SCSS vs CSS – the basics</a></li>
                    <li><a href="#Installing-Webpack">2.  Installing Webpack</a></li>
                    <li><a href="#Installing-Gulp">3.  Installing Gulp</a></li>
                    <li><a href="#Webpack-Configuration">4.  Webpack Configuration</a></li>
                    <li><a href="#Gulp-Configuration">5.  Gulp Configuration</a></li>
                    <li><a href="#Gulp-vs-Webpack-tool-handling-–-comparison">6.  Gulp vs Webpack tool handling – comparison</a></li>
                    <li><a href="#Gulp-or-Webpack?">7.  Gulp or Webpack?</a></li>
                    <li><a href="#How-about-using-Webpack-instead-of-Gulp?">8.  How about using Webpack instead of Gulp?</a></li>
                    <li><a href="#Gulp-vs-Webpack-comparison-–-summary">9.  Summary</a></li>
            </ol>
</div>


<p><strong>Gulp vs Webpack</strong>? Both of these tools play an important role in the world of programming. Often the choice between them seems complicated at first glance. However, understanding their differences and similarities will undoubtedly help us make the right decision – especially those who are new to the world of programming. Whether we&#8217;re considering using <strong>Gulp (task runner)</strong>, <strong>Webpack (module bundler)</strong>, or a combination of both, knowing more about their functionalities will definitely make our job easier and increase our level of productivity. If you&#8217;re looking for the right tools for your next project, read on.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img fetchpriority="high" decoding="async" width="756" height="200" src="https://nearshore-it.eu/wp-content/uploads/2023/09/nearshore_2023.08.23_graphic_1.png" alt="Gulp vs Webpack" class="wp-image-25210" title="Gulp vs Webpack. What is better: Using Webpack or Gulp.js? 1" srcset="https://nearshore-it.eu/wp-content/uploads/2023/09/nearshore_2023.08.23_graphic_1.png 756w, https://nearshore-it.eu/wp-content/uploads/2023/09/nearshore_2023.08.23_graphic_1-300x79.png 300w, https://nearshore-it.eu/wp-content/uploads/2023/09/nearshore_2023.08.23_graphic_1-495x131.png 495w" sizes="(max-width: 756px) 100vw, 756px" /></figure></div>


<h2 class="wp-block-heading" id="SCSS-vs-CSS-–-the-basics">SCSS vs CSS – the basics</h2>



<p>Before comparing the tools (<strong>Webpack and Gulp</strong>), let&#8217;s remind ourselves of what CSS and SCSS technologies are – apart from being indispensable in the world of programming, of course.</p>



<p>CSS and SCSS are technologies we use daily to assign specific appearances to elements (color, size) and position these elements on the page. However, it&#8217;s essential to consider certain differences before deciding to use any of them.</p>



<p>CSS is the standard stylesheet language, firmly rooted in the front-end world. Compared to SCSS, its syntax appears simpler and much more intuitive. Younger developers definitely tend to choose CSS, especially in the early stages of their learning. CSS rules aim to define styles for specific elements, such as paragraphs, divs, or other HTML elements.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">/* CSS syntax */

h1 { color: blue; font-size: 24px; }</pre>



<p>SCSS is simply a CSS preprocessor, it extends the syntax with additional functions and allows for the use of advanced techniques, including:</p>



<ul class="wp-block-list"><li><strong>nesting rules</strong> – CSS selectors can be nested within other selectors, reflecting the structure of HTML selectors.</li><li><strong>using variables</strong> (which enable storing reusable values throughout your stylesheet),</li><li><strong>mathematical operators </strong>(allowing for operations like addition, subtraction, multiplication, and division within your styles), making your code easier to write, more modular, and more elegant.</li></ul>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">/* SCSS syntax with nesting and variables */

$primary-color: blue;

h1 {

color: $primary-color;

font-size: 24px;

}</pre>



<h3 class="wp-block-heading">Key differences between SCSS and CSS:</h3>



<ol class="wp-block-list"><li><strong>Syntax</strong>: SCSS offers a more expanded syntax, which makes writing and maintaining code more straightforward. Nesting rules allow for more readable and logical code.</li><li><strong>Variables</strong>: SCSS enables the definition of variables, allowing for easy changes to style values in one place, and promoting consistency across a project.</li><li><strong>Preprocessor</strong>: SCSS is one of many CSS preprocessors, meaning SCSS code needs to be compiled into regular CSS before deployment on a web page.</li></ol>



<p>The choice between SCSS and CSS depends on the complexity of the project and the team&#8217;s skillset. For straightforward projects that don&#8217;t require advanced styling techniques, CSS might be a suitable choice. However, for more complex projects where modularity and easy edits are crucial, SCSS can provide greater flexibility and convenience when it comes to managing styles.</p>



<p>Read also: <a href="https://nearshore-it.eu/articles/project-management-leadership/front-end-development-outsourcing/" target="_blank" data-type="URL" data-id="https://nearshore-it.eu/articles/project-management-leadership/front-end-development-outsourcing/" rel="noreferrer noopener">Front-End development outsourcing</a></p>



<h2 class="wp-block-heading" id="Installing-Webpack">Installing Webpack</h2>



<p>The features of Webpack primarily allow for managing dependencies and creating organized files. Installing the tool is ridiculously easy. Let&#8217;s start by checking if we have the Node Package Manager (NPM) installed, which is, in my opinion, the quickest and most efficient way to install Webpack. Next, we open the command line and type in the command:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npm install webpack –g</pre>



<p>Then, from the command line, we navigate to the directory with our project and type the command:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npm init</pre>



<p>We can notice that a package.json file has been created in the target directory. All that&#8217;s left is to install Webpack in our project:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npm install --save-dev webpack</pre>



<p>And now we can enjoy this powerful tool!</p>



<p>Further configuration steps depend on the individual needs of the project – I will describe an example of a brief configuration in the points below. However, detailed guidelines regarding Webpack&#8217;s capabilities can be found in the official documentation available on the website: Webpack Documentation.</p>



<h2 class="wp-block-heading" id="Installing-Gulp">Installing Gulp</h2>



<p>On the other hand, we use Gulp for automating certain tasks, such as compilation, minification of files, images, or refreshing the browser. Installing Gulp is just as easy as installing Webpack. Let&#8217;s ensure that we have NPM installed. Then, we start with the command:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npm install -g gulp</pre>



<p>We navigate to our project directory, creating a package.json file by using the command:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npm init</pre>



<p>And all that&#8217;s left for us is to add Gulp to our project:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npm install --save-dev gulp</pre>



<p>How do we configure Webpack? After installation, we can start creating the gulpfile.js file, which will be responsible for task configuration for our tool. Later in the article, I will also provide a brief configuration for Gulp.</p>



<p>To explore all the capabilities of Gulp, the Gulp is available.</p>



<h2 class="wp-block-heading" id="Webpack-Configuration">Webpack Configuration</h2>



<p>As I mentioned earlier, I will present a brief configuration of Webpack in our project. It&#8217;s such an advanced tool that I can’t describe all its capabilities here.</p>



<p>Let&#8217;s start by adding a <strong>webpack.config.js</strong> file, which contains the entire Webpack configuration.</p>



<p>Next, let&#8217;s place the basic configuration there:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">module.exports = {

entry: './src/main.js',

output: {

path: __dirname + '/dist',

filename: 'bundle.js'

},

mode: 'production'

};</pre>



<p>We defined where Webpack should fetch the source files (entry). The output property specifies where they should be placed after processing. The mode option determines whether we want to optimize the code, for example, for production. Webpack provides us with a broad package of plugins and loaders, allowing us to tailor it to our needs.</p>



<h2 class="wp-block-heading" id="Gulp-Configuration">Gulp Configuration</h2>



<p>Gulp is a task automation tool that we can customize in the gulpfile.js file. Within the configuration, we define tasks such as code minification, compilation, or refreshing the browser after every change in the code.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">const gulp = require('gulp');

const uglify = require('gulp-uglify');

gulp.task('compress', function() {

return gulp.src('src/js/*.js')

.pipe(uglify())

.pipe(gulp.dest('dist/js'));

});</pre>



<p>This is a sample configuration, the aim of which is to compress JavaScript files.</p>



<p>First, we create a new task called &#8216;compress&#8217;. Then, with return <strong>gulp.src(&#8216;src/js/*.js&#8217;)</strong>, we specify the source files to be processed (in our case, these are all files with the .js extension, from the src/js directory).</p>



<p>The next step is to pass the source files to the plugin <strong>using pipe(uglify())</strong>, which compresses our code, removing, for example, unnecessary spaces and comments so that the file is as small as possible.</p>



<p>Finally, we indicate the directory where the processed files should be saved.</p>



<h2 class="wp-block-heading" id="Gulp-vs-Webpack-tool-handling-–-comparison">Gulp vs Webpack tool handling – comparison</h2>



<p>If we were to compare Webpack and Gulp, it&#8217;s hard to pinpoint a single correct choice – it all depends on the project we&#8217;re currently working on.</p>



<p>Webpack is primarily a bundler that compiles project assets into clear outputs. We can easily extend it thanks to plugins, which allows us to achieve a wide range of applications, such as:</p>



<ul class="wp-block-list"><li><strong>Transpilation </strong>– in the case of JavaScript, for example, adapting the ES6 version to older browsers,</li><li><strong>Code minification</strong> &#8211; the process of removing unnecessary characters from code to reduce its size, thereby improving load times),</li><li><strong>Dependency management.</strong> </li></ul>



<p>Check all Gulp plugins available: <a href="https://gulpjs.com/docs/en/getting-started/using-plugins/" data-type="URL" data-id="https://gulpjs.com/docs/en/getting-started/using-plugins/" target="_blank" rel="noreferrer noopener">Using plugin</a>.</p>



<p>On the other hand, Gulp is a task automation tool that will definitely improve our workflow. In my opinion, it is very easy to learn. In a short time, we can create tasks for compiling SASS files or automatic browser refresh. The configuration is much more readable and flexible.</p>



<p>Webpack handles dependencies superbly, while Gulp stands out when we want to fully automate our work.</p>



<p><strong>In a nutshell:</strong></p>



<ul class="wp-block-list"><li>Webpack is a module bundler. Like Gulp, Webpack also allows you to run many functions related to tasks.</li><li>Gulp is a task automation tool to enhance your workflow.</li></ul>



<h2 class="wp-block-heading" id="Gulp-or-Webpack?">Gulp or Webpack?</h2>



<p>The choice between these two technologies depends on the specific needs and architecture of our project. It is also a matter of personal preferences and experience. If complex bundling and dependency management are crucial to your development process, Webpack might be the right way to go. On the other hand, if you need a simple and clear way to automate typical developer tasks, Gulp is an excellent solution. This article is really an introduction to these tools. At each stage, it is useful to use documentation and take advantage of the knowledge of experienced colleagues and Technical Leaders in a project.</p>



<p>Remember, nothing prevents us from combining both tools. By using Gulp and Webpack simultaneously, we can benefit from the advantages of each. This can not only improve the quality of our project but also reduce the time needed for development.</p>



<h2 class="wp-block-heading" id="How-about-using-Webpack-instead-of-Gulp?">How about using Webpack instead of Gulp?</h2>



<p>When combined with NPM scripts, Webpack can successfully replace Gulp. In my experience, however, it is better to combine tools rather than limit yourself to just one, which I strongly encourage you to do. As I mentioned, Webpack and Gulp are both build tools that you can use for similar tasks. However, their approaches and strengths differ. Ultimately, the choice between using</p>



<p>Webpack alone or combining it with Gulp depends on the requirements of your project and your preference as a programmer.</p>



<h2 class="wp-block-heading" id="Gulp-vs-Webpack-comparison-–-summary">Gulp vs Webpack comparison – summary</h2>



<p>I hope I have been able to clarify the benefits of using Webpack and Gulp. When it comes to the question of &#8216;Webpack or Gulp&#8217;, it&#8217;s hard to find one perfect solution, especially in the case of beginner front-end developers. Above all, we need to focus on our skills, experience, and project needs. There is no universal solution. Often, we have a predetermined work ecosystem. It&#8217;s worth experimenting with both technologies, combining them, testing, and creating an optimized, efficient work environment.</p>



<figure class="wp-block-table"><table><tbody><tr><td><br></style><div class="promotion-box promotion-box--image-left "><div class="tiles latest-news-once"><div class="tile"><div class="tile-image"><img decoding="async" src="https://nearshore-it.eu/wp-content/uploads/2022/12/nearshore_2022.12.01_cover.jpg" alt="nearshore 2022.12.01 cover" title="Gulp vs Webpack. What is better: Using Webpack or Gulp.js? 2"></div><div class="tile-content"><p class="entry-title client-name">APPLICATION DEVELOPMENT SERVICES</p>

<h3Transform your business with our custom application development and end-to-end software solutions</h3>
From initial analysis and design to development, testing, and maintenance, we manage every aspect of the process.
<a class="btn btn-primary" href="https://nearshore-it.eu/application-development/">Explore our services today!</a></div></div></div></div></td></tr></tbody></table></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://nearshore-it.eu/technologies/gulp-vs-webpack-what-is-better/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Reactive programming in JavaScript – RxJS pros and cons </title>
		<link>https://nearshore-it.eu/technologies/rxjs-reactive-javascript/</link>
					<comments>https://nearshore-it.eu/technologies/rxjs-reactive-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Maciej Woźnica]]></dc:creator>
		<pubDate>Mon, 13 Feb 2023 12:57:13 +0000</pubDate>
				<category><![CDATA[Technologies]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://nearshore-it.eu/?p=22068</guid>

					<description><![CDATA[Reactive programming – in the introduction to this programming approach, I will present its capabilities using the example of the RxJS library. Read the introduction to reactive functional programming and get to know the advantages and disadvantages of RxJS.]]></description>
										<content:encoded><![CDATA[
<p>Modern web applications require more efficient solutions from developers. The days when the main functionality of the website was to display static text, handle clicks or send messages via a form are long gone. Very often, as developers, we face challenges related to user demands and growing data volume, which significantly affect website performance. Here reactive programming comes in handy – in the introduction to this programming approach, I will present its capabilities using the example of the RxJS library. Read the introduction to reactive functional programming and get to know the advantages and disadvantages of RxJS.&nbsp;</p>



<div class="table-of-contents">
    <p class="title">Go to:</p>
    <ol>
                    <li><a href="#Why-use-RxJS?-Challenges-for-developers-of-modern-web-applications">1.  Why use RxJS? Challenges for developers of modern web applications</a></li>
                    <li><a href="#Data-Streams">2.  Data Streams</a></li>
                    <li><a href="#What-is-RxJS-observable?">3.  What is RxJS observable?</a></li>
                    <li><a href="#Observable-vs-JavaScript-promises">4.  Observable vs JavaScript promises</a></li>
                    <li><a href="#Hot-vs-cold-observables">5.  Hot vs cold observables</a></li>
                    <li><a href="#Creating-observables-and-execution-of-observable">6.  Creating observables and execution of observable</a></li>
                    <li><a href="#Operators">7.  Operators</a></li>
                    <li><a href="#Subscriptions">8.  Subscriptions</a></li>
                    <li><a href="#Observer">9.  Observer</a></li>
                    <li><a href="#RxJS-pros-">10.  RxJS pros </a></li>
                    <li><a href="#RxJS-cons">11.  RxJS cons</a></li>
                    <li><a href="#Features-of-RxJS-–-the-summary">12.  Features of RxJS – the summary</a></li>
            </ol>
</div>


<h2 class="wp-block-heading" id="Why-use-RxJS?-Challenges-for-developers-of-modern-web-applications">Why use RxJS? Challenges for developers of modern web applications</h2>



<p>When creating modern and efficient web applications, we are faced with numerous challenges. <strong>As developers, we need to bear in mind that, for example, we cannot block a user and make them wait until our website handles several events. </strong>So, what should we do if the application has to run an animation, load a loader, and react to the user’s action? How do you make it possible to handle all these situations at the same time? Here the paradigm of reactive programming with the RxJS library comes in handy.&nbsp;</p>



<p>Reactive programming is a paradigm for writing code based on asynchronous data streams.<br>It is a way of creating applications that respond to changes, as opposed to the typical, imperative way of programming, in which we explicitly make step-by-step instructions to handle these changes.<br>It sounds quite complicated as such an approach calls for a change in the way of thinking. However, thanks to certain solutions, <strong>you can smoothly switch to reactive programming – in the case of JavaScript, the RxJS library.&nbsp;</strong></p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="756" height="198" src="https://nearshore-it.eu/wp-content/uploads/2023/02/nearshore_2023.03.xx_graphic_1.png" alt="" class="wp-image-22074" title="Reactive programming in JavaScript – RxJS pros and cons  3" srcset="https://nearshore-it.eu/wp-content/uploads/2023/02/nearshore_2023.03.xx_graphic_1.png 756w, https://nearshore-it.eu/wp-content/uploads/2023/02/nearshore_2023.03.xx_graphic_1-300x79.png 300w, https://nearshore-it.eu/wp-content/uploads/2023/02/nearshore_2023.03.xx_graphic_1-495x130.png 495w" sizes="(max-width: 756px) 100vw, 756px" /></figure></div>


<h2 class="wp-block-heading" id="Data-Streams">Data Streams</h2>



<p>A stream is a sequence of data ordered over time. Data streams can be created from objects, variables, data structures, events (clicks), HTTP request responses, etc.<br>On its timeline, the stream can also emit an error (when an unexpected event occurs causing the stream to end) or earn completed status (which means <strong>the stream has emitted all the data</strong>). We can capture these methods (<strong>error and complete</strong>) to perform appropriate operations on them – you will find out more in the paragraphs below.</p>


</style><div class="promotion-box promotion-box--image-left "><div class="tiles latest-news-once"><div class="tile"><div class="tile-image"><img decoding="async" src="https://nearshore-it.eu/wp-content/uploads/2024/06/BigCTA_MarekCzachorowski.jpg" alt="BigCTA MarekCzachorowski" title="Reactive programming in JavaScript – RxJS pros and cons  4"></div><div class="tile-content"><p class="entry-title client-name promotion-box__headline2">Elevate Your Application Development</p>
<p class="promotion-box__description2">Our tailored Application Development services meet your unique business needs. Consult with <strong>Marek Czachorowski</strong>, Head of Data and AI Solutions, for expert guidance.</p>
<a class="btn btn-primary booking" href="https://outlook.office365.com/book/BookameetingwithMarek@gfi.fr/" target="_blank" rel="noopener">Schedule a meeting</a></div></div></div></div>



<h2 class="wp-block-heading" id="What-is-RxJS-observable?">What is RxJS observable?</h2>



<p>RxJS uses observable objects that use an observer design pattern.<br>To illustrate how it works, let’s use the example of subscribing to a newsletter. You have likely clicked the “subscribe” button on YouTube or a blog many times already. When a new article or other material appears, you are notified straight away. Unsubscribing is possible at any time.</p>



<h2 class="wp-block-heading">Subscribe&nbsp;</h2>



<p>Observable and streams work the same way.</p>



<ul class="wp-block-list">
<li>By clicking the subscribe button, you become an observer of a given resource.</li>



<li>Observable as an observed object gives us a data stream with news.</li>



<li>The subscription to the stream provides us with the ‘subscribe’ method.</li>



<li>We can also choose which data is valuable to us as ‘news’.</li>
</ul>



<h2 class="wp-block-heading" id="Observable-vs-JavaScript-promises">Observable vs JavaScript promises</h2>



<p>Observable is a stream of values (of any type). But wait… Why do we need this observable stuff when we already have a promise object in JavaScript? Observable gives us a lot more possibilities. Here is a short comparison:</p>



<h3 class="wp-block-heading">Promise</h3>



<ul class="wp-block-list">
<li>it is asynchronous each time,</li>



<li>it is ‘eager’ – processing starts immediately after an object is defined,</li>



<li>it can only return one value,</li>



<li>it has no operators,</li>



<li>it cannot be canceled.</li>
</ul>



<h3 class="wp-block-heading">Observable</h3>



<ul class="wp-block-list">
<li>it can be both synchronous and asynchronous,</li>



<li>it is ‘lazy’ – this means that it won’t be executed at the moment of defining the stream, but when the subscription is created,</li>



<li>it returns one or more values,</li>



<li>there are a number of operators to use,</li>



<li>we can cancel it any time,</li>



<li>it gives us more options when handling errors (e.g. retry operator ()),</li>
</ul>



<h2 class="wp-block-heading" id="Hot-vs-cold-observables">Hot vs cold observables</h2>



<p>We can divide observables into hot and cold.</p>



<h3 class="wp-block-heading">Cold observables:</h3>



<ul class="wp-block-list">
<li>Emitting values begins with the first subscriber (when the first subscribe() appears – read more later in the article).</li>



<li>They return new values for each new subscriber.</li>



<li>Example: the service for downloading data from the backend, where we need to subscribe in order to execute the query.</li>
</ul>



<h3 class="wp-block-heading">Hot observables:</h3>



<ul class="wp-block-list">
<li>They send values despite the lack of a subscriber.</li>



<li>They share the same data among all subscribers.</li>



<li>Example: observable created from a click event.</li>
</ul>



<h2 class="wp-block-heading" id="Creating-observables-and-execution-of-observable">Creating observables and execution of observable</h2>



<p>There are many ways to create an observable. Creating them from other data structures is also common – here of or from operators are helpful. In RxJS, creating one observable of several other observables is not a problem. Below are some examples:</p>



<h3 class="wp-block-heading">Observable examples</h3>



<p>The from operator can be iterated over only one argument (e.g. arrays, array-like elements – let’s take an array of objects as an example).</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import { from, Observable } from 'rxjs'; 

  

const to ReadBooks = [ 

{ bookId: 1, title: The psychology of money', author: 'Morgan Housel' 

publicationYear: 2020 }, 

{ bookId: 2, title: 'The subtle art of not giving a f*ck', author: 'Mark Manson', publicationYear: 2016 }, 

{ bookId: 3, title: How to talk to anyone', author: 'Leil Lowndes', publicationYear: 1999 }, 

{ bookId: 3, title: 'Invent and wander', author: Jeff Bezos', publicationYear: 2020 }, 

  

]; 

  

let source2$ = from(toReadBooks); 

source2$.subscribe(book =&amp;gt; console.log(book.title));</pre>



<p><strong>This way, the array of objects has turned into an observable. Easy, isn’t it?</strong></p>



<h2 class="wp-block-heading" id="Operators">Operators</h2>



<p>What if there are several streams and we need one observable? No problem! RxJS provides several operators to help us. One of them is a concat.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import { concat, from, Observable, of } from 'rxjs'; 

  

const toReadBooks = [ 

  

  

{ bookId: 1, title: The psychology of money', author: 'Morgan Housel' 

publicationYear: 2020 }, 

{ bookId: 2, title: 'The subtle art of not giving a f*ck', author: 'Mark Manson', publicationYear: 2016 },  

{ bookId: 3, title: How to talk to anyone', author: 'Leil Lowndes', publicationYear: 1999 }, 

{ bookId: 3, title: 'Invent and wander', author: Jeff Bezos', publicationYear: 2020 }, 

  

]; 

  

let source1$ = of('hello', 10, true, toReadBooks[0].title); 

source1$.subscribe(value =&amp;gt; console.log(value)); 

  

let source2$ = from(toReadBooks); 

source2$.subscribe(book =&amp;gt; console.log(book.title 

  

// combine the 2 sources 

concat(source1$, source2$) 

.subscribe(value =&amp;gt; console.log(value));</pre>



<p><strong>Voilà! RxJS makes life easier!</strong></p>



<h2 class="wp-block-heading" id="Subscriptions">Subscriptions</h2>



<p>I mentioned the option of ‘subscribing’ to the stream. Another term that seems complicated at first (but isn’t!). A subscription simply means connecting to a stream. Each observable has a subscribe() method, to which we can pass parameters in two ways: as an object with methods or as a set of callbacks. The object passed to the subscribe method is called an observer.</p>



<h2 class="wp-block-heading" id="Observer">Observer</h2>



<p>The observer has three components:</p>



<ul class="wp-block-list">
<li>The first method (next) is executed if we manage to get the value from the stream. Each new value invokes this method.</li>



<li>The second method (error) is executed if an error occurs in the stream, ; for example, in the HTTP query we get the status 500. In the event of an error, our observer will not proceed and will not perform the complete method, and thus will be marked as closed and will stop emitting values.</li>



<li>The third method (complete) is executed when the stream emits the last value.</li>
</ul>


</style><div class="promotion-box promotion-box--image-left "><div class="tiles latest-news-once"><div class="tile"><div class="tile-image"><img decoding="async" src="https://nearshore-it.eu/wp-content/uploads/2023/05/nearshore_2023.05.25_social.jpg" alt="nearshore 2023.05.25 social" title="Reactive programming in JavaScript – RxJS pros and cons  5"></div><div class="tile-content"><p class="entry-title client-name">Nearshoring services</p>
Entrust your project to nearshore software development experts
<a class="btn btn-primary" href="https://nearshore-it.eu/it-nearshoring-services/" target="_blank" rel="noopener">Get started now!</a></div></div></div></div>



<h2 class="wp-block-heading" id="RxJS-pros-">RxJS pros&nbsp;</h2>



<p>The RxJS library undoubtedly facilitates application development. It can be integrated with practically any frontend framework <strong>(Angular, React)</strong>. Also, using pure JavaScript is not a problem. There is a wide range of operators to use which allow you to modify streams in any way. Frequent updates make subsequent editions of the library easier to use. Thanks to RxJS, we can speed up, as well as improve the quality of software.</p>



<h2 class="wp-block-heading" id="RxJS-cons">RxJS cons</h2>



<p>I find it harder to write something about the disadvantages than the advantages. <a href="https://www.jcommerce.eu/jpro/articles/angular-create-your-own-progressive-web-application" target="_blank" data-type="URL" data-id="https://www.jcommerce.eu/jpro/articles/angular-create-your-own-progressive-web-application" rel="noreferrer noopener">Working with Angular every day</a>, I can’t imagine writing even one component without the RxJS library. Certainly, it might be difficult – especially for beginners – to test RxJS code. Testing such code calls for knowledge of many additional techniques and tools. Fortunately, RxJS has a solution for this in the form of RxJS Marbles. It allows us, step by step, to test asynchronous RxJS code synchronously, using the<strong> RxJS TestScheduler </strong>test tool and virtual time steps. However, this is an extensive issue that could better be described in a separate article.</p>



<h2 class="wp-block-heading" id="Features-of-RxJS-–-the-summary">Features of RxJS – the summary</h2>



<p>The above is a very broad description of reactive programming and the RxJS library. A new article could be written on each of the above matters, and mine is just a drop in the ocean – many aspects have been skipped over.<br>Undoubtedly, <strong>RxJS has become standard for developing modern and efficient applications. </strong>Continuous development and support for the most popular frameworks make RxJS by far the most frequently used library, allowing us to control asynchrony.</p>


</style><div class="promotion-box promotion-box--image-left promotion-box--full-width-without-image"><div class="tiles latest-news-once"><div class="tile"><div class="tile-content"><p class="promotion-box__description2"><strong>Consult your project directly with a specialist</strong></p>
<a class="btn btn-primary booking" href="https://outlook.office365.com/book/BookameetingwithMarek@gfi.fr/" target="_blank" rel="noopener">Book a meeting</a></div></div></div></div>



<p><strong>Read more: <a href="https://nearshore-it.eu/articles/technologies/aws-lambda-serverless-applications/">Using AWS Lambda functions</a></strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://nearshore-it.eu/technologies/rxjs-reactive-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Framework wars</title>
		<link>https://nearshore-it.eu/best-practices/framework-wars/</link>
					<comments>https://nearshore-it.eu/best-practices/framework-wars/#respond</comments>
		
		<dc:creator><![CDATA[Rafal Baran]]></dc:creator>
		<pubDate>Tue, 25 Feb 2020 11:21:00 +0000</pubDate>
				<category><![CDATA[Best practices]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://nearshore-it.eu/?p=25345</guid>

					<description><![CDATA[What is a framework and which one should you choose? Read the article and dive into the world of frameworks.]]></description>
										<content:encoded><![CDATA[
<p>In my daily job as a&nbsp;<a href="https://www.jcommerce.eu/it-services/software-development/php" target="_blank" rel="noopener">PHP software developer</a>&nbsp;I like to use frameworks because they are the result of community collaboration – so I don’t have to solve problems that have already been solved and focus on higher application layer. But at the same time every user, including me, can have an impact on them.</p>



<div class="table-of-contents">
    <p class="title"></p>
    <ol>
                    <li><a href="#Pros-and-cons-of-frameworks">1.  Pros and cons of frameworks</a></li>
                    <li><a href="#How-to-use-frameworks-properly">2.  How to use frameworks properly?</a></li>
                    <li><a href="#Multi-framework-approach">3.  Multi-framework approach</a></li>
                    <li><a href="#Summary">4.  Summary</a></li>
            </ol>
</div>


<p>For my technology there are many frameworks available on the market so it’s not difficult to choose the most convenient for the particular project or individual preferences. But let’s take a look at all areas of programming where frameworks can be used.</p>



<p>The areas where we can use frameworks in IT are:</p>



<ul class="wp-block-list"><li><strong>For compilers of different programming languages</strong>&nbsp;– programs for the automatic translation of code written in one language to the equivalent code in a second language.</li><li><strong>Applications for financial modeling.</strong></li><li><strong>Applications for earth science modeling.</strong></li><li><strong>Decision support systems</strong>&nbsp;– systems that deliver information and knowledge.</li><li><strong>Web applications</strong>&nbsp;– computer programs which work on servers through computer networks and connect with users’ computers by means of internet browser.</li><li><strong>Middleware</strong>&nbsp;– software between different applications, services or systems.</li></ul>



<p>On today’s software market we have many ready-to-use solutions, and most of them are based on frameworks, because they have to keep architecture at a high level of clarity and formalization to enable software developers to make further modifications. This features a high level of complexity, but it is worth learning new technologies and solutions because they can accelerate your work or that of your team. Let’s consider it in even greater detail and take a look at the list of pros and cons of frameworks.</p>



<p><strong>Read also:&nbsp;<a href="https://www.jcommerce.eu/jpro/articles/clean-architecture-en" target="_blank" rel="noopener">Clean Architecture</a></strong></p>



<h2 class="wp-block-heading" id="Pros-and-cons-of-frameworks">Pros and cons of frameworks</h2>



<h3 class="wp-block-heading">Pros:</h3>



<ul class="wp-block-list"><li><strong>Efficiency</strong>&nbsp;– building applications with frameworks requires the software developer to write less code,</li><li><strong>Improved quality of code</strong>&nbsp;– because frameworks are designed to be flexible, they have good internal logic, and they impose the same logic on the created application,</li><li><strong>Reliability</strong>&nbsp;– frameworks such as application skeletons are well-projected and tested.</li></ul>



<h3 class="wp-block-heading">Cons:</h3>



<ul class="wp-block-list"><li><strong>Complexity</strong>&nbsp;– learning frameworks is difficult because of flexible and advanced usage,</li><li><strong>Performance</strong>&nbsp;– instead of the flexible construction of the software which has been created, we often get a lower level of performance (at this point I have to mention cache systems that can improve the performance of frameworks in a large percentage of server responses).</li></ul>



<p>As we can see, we have more pros than cons, which in my opinion is the biggest advantage of frameworks. However, we have to be aware that frameworks are not always the best solution. For example, if we need to create an application to display a single message on screen as a server response, the usage of frameworks will slow down the server response and the execution of our application. Such an application needs only one command to execute and no additional tools are necessary.</p>



<h2 class="wp-block-heading" id="How-to-use-frameworks-properly">How to use frameworks properly?</h2>



<p>Of course, I wouldn’t say that frameworks can resolve all our problems with software, but they can certainly help us with our daily tasks. On the other hand, we have to be careful here. Too many times I’ve seen fights on community forums dedicated to a given framework, where people try to prove that the framework which they have chosen is the best.</p>



<p>I believe that&nbsp;<strong>frameworks are like tools</strong>&nbsp;<strong>– the more tools you have, the more problems you can solve.</strong>&nbsp;If you only have a hammer, you can probably only hammer a nail. But if you have a shed full of tools you can do whatever you want.</p>



<h2 class="wp-block-heading" id="Multi-framework-approach">Multi-framework approach</h2>



<p>This approach is supported by the architecture of today’s applications, which are built from packages – separable modules with their own requirements that we can use to create any kind of application. That way, the application can be divided into smaller parts and is easier for more people to understand. Packages also organize the structure of applications and help to develop larger projects.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" src="https://www.jcommerce.pl/wp-content/uploads/2020/02/Framework_graphic_1.png" alt="Frameworki" class="wp-image-25759" title="Framework wars 6"></figure></div>


<p>According to this idea, we can use packages as independent software and install them to build our application. There is no obstacle to the use of frameworks in the same way – each part of our application can be built on a different framework. Why? When we use libraries created for only one framework, we are not able to utilize software created for other frameworks. In summary – we should use the approach that allows us to remain open to other possibilities: the multi-framework approach.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" src="https://www.jcommerce.pl/wp-content/uploads/2020/02/Framework_graphic_2.png" alt="Framework" class="wp-image-25760" title="Framework wars 7"></figure></div>


<h2 class="wp-block-heading" id="Summary">Summary</h2>



<p>The multi-framework approach can be seen in&nbsp;<strong>popular solutions</strong>&nbsp;like&nbsp;<strong>Magento</strong>&nbsp;(e-commerce platform),&nbsp;<strong>Sylius</strong>&nbsp;(e-commerce platform) or next generation e-commerce shop which calls&nbsp;<strong>Shopware</strong>, there is a not only e-commerce application – where we can see it, also at popular and highly flexible CMF frameworks such as&nbsp;<strong>Sulu</strong>. When you check the source code of these applications on GitHub, you will see that the authors have used packages from Zend &amp; Symfony frameworks – those packages are manageable in PHP technology via a composer service. The proportions aren’t huge at first glance, but we can start to consider it a multi-framework usage and treat is as a conscious architectonic decision.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nearshore-it.eu/best-practices/framework-wars/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PWA – the Front-End revolution</title>
		<link>https://nearshore-it.eu/technologies/pwa-the-front-end-revolution/</link>
		
		<dc:creator><![CDATA[Karolina Czachura]]></dc:creator>
		<pubDate>Thu, 05 Sep 2019 08:10:03 +0000</pubDate>
				<category><![CDATA[Technologies]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://nearshore-it.eu/?p=7501</guid>

					<description><![CDATA[In recent years, e-commerce has been gathering pace. In 2019 the ecommerce market will generate 50 billion PLN in trade turnover, which constitutes about 10% of the entire trade sector. This trend has its origins in generational change, followed by the development of mobile technologies. New legal regulations are also important here, such astrade bans on Sundays. One of the factors which causes us to cease visiting shops is convenience – thanks to user-friendly aspects, we make purchasing decisions easier and faster. Due to this tendency, an increasing number of e-commerce businesses are using Progressive Web Applications (PWA) for their business websites.]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PWA means: simplicity, comfort and action</h2>



<p>PWA is nothing more than a version of a web page functioning just like a mobile application on a smartphone.</p>



<p><strong>See more: <a href="/software-development/mobile-app-outsourcing-company/">Mobile development team</a></strong></p>



<p> There are a couple of guidelines that PWA must meet. </p>



<ul class="wp-block-list"><li><strong>HTTPS</strong>: the application uses encrypted protocol, thanks to which we can display pages, use forms and download files. Encryption prevents the capture of and changes to the data that is being sent. </li><li><strong>Front-End</strong> of the application, ensuring responsiveness. Thanks to this, the application adjusts its appearance depending on the device.</li><li><strong>Offline </strong>regardless of access to the Internet, the application has some particular functionalities.</li><li>The application has a manihest.json&nbsp;file, which allows users to add <strong>shortcut icons to the start screens</strong>, analogically to mobile applications. </li><li>Even when using slow 3G connections, the application <strong>loads quickly.</strong></li><li>High level of reactiveness to user actions, such as switching pages. </li></ul>



<p>PWA are used by corporations from all over the world. Some of the leading ecommerce examples are Uber, Lyft, Starbucks and Trivago. We can also find examples of PWA implementations on the Polish market, which have resulted in better outcomes. <strong>Thanks to Progressive Web Application, OLX has 146% more advertising clicks on their web portal. What is more, the Bounce Rate (the number of people who leave the page after only a couple of seconds) decreased by 80%.</strong> This must have resulted in increased attractiveness of the portal for both users and advertisers. </p>



<p><strong>Also read: <a href="https://nearshore-it.eu/articles/technologies/angular-pwa/">Creating PWA with Angular</a></strong></p>



<h2 class="wp-block-heading">The hottest Front-End technology of recent years </h2>



<p>PWA technology has been talked about for a
number of years now, and the fact that it is promoted by Google and Microsoft
results in the subject of PWA coming up during the biggest conferences. PWA has
a lot to offer for businesses and users of their websites. </p>



<p><strong>Firstly, Progressive Mobile Applications have comparable results with those of mobile applications when it comes to positioning. </strong>As they are Google-supported, it is possible that within a couple of years it will be possible to gain some extra ranking points here. Reliability is another feature of this technology. The script embedded in the Front-End controls the cache and shares the sources which are saved there. Thanks to this, we gain independence when it comes to Internet access. </p>



<p>Regardless of the quality of the connection, the application loads quickly thanks to the Service Worker mechanism. Swiftness in the functioning of the website is a key factor. <strong>According to Google, 53% of users will leave a page if it doesn’t load within three seconds.</strong> Well-developed PWA ensures good functioning and rapid reactions to commands. The attractiveness of PWA sources arises from their similarity to native applications, beloved by customers once a wide range of smartphones became available on the market.</p>



<h2 class="wp-block-heading">Changing the website into PWA</h2>



<p>The internet is full of guides on how to change one’s website to a well-functioning application. <strong>A basic knowledge of Front-End should be sufficient here (HTML + CSS + Java Script).</strong> Google provides access to an expanded service, which helps in the creation of a well-functioning PWA. We encounter issues here, however, when we own an online shop or a dedicated web service.</p>



<p>Obtaining the best results will be most likely when cooperating with an experienced business partner. JCommerce as the one of the <a href="https://www.softwaredevelopmentcompany.co/web-development-companies/" target="_blank" rel="noopener">Top Web Development Companies</a> offers the services of experienced Front-End developers. The company can offer various cooperation models, including in the context of building entire <a href="/team-delivery/">Front-End and PHP teams</a>. They provide the scalability of development process, which allows to transform all the type of web application to progressive.</p>



<h2 class="wp-block-heading"><strong>T</strong>he future of PWA</h2>



<p>The possibilities created by current Front-End
technologies facilitate the development of user-friendly e-commerce solutions.
Progressive Web Applications mean the beginning of a revolution in terms of
online shops. In the future, ponderous e-markets with glittering banners will
be replaced by e-salons which are easy on the eye. Even nowadays we do our shopping
more eagerly while using websites which are visually attractive; it is hard for
us to imagine making e-payments via portals which resemble the unpleasant-looking
creations from the ‘90s. The high quality of the products is important, yet even
more important is our experience – and this is certainly what PWA can offer.</p>



<hr class="wp-block-separator has-css-opacity"/>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Why Would a Back-End Programmer Love Angular?</title>
		<link>https://nearshore-it.eu/technologies/software-development-angular-for-back-end-programmers-2/</link>
					<comments>https://nearshore-it.eu/technologies/software-development-angular-for-back-end-programmers-2/#respond</comments>
		
		<dc:creator><![CDATA[Igor Trafalski]]></dc:creator>
		<pubDate>Wed, 13 Jun 2018 09:18:00 +0000</pubDate>
				<category><![CDATA[Technologies]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://nearshore-it.eu/?p=25075</guid>

					<description><![CDATA[Angular is a framework which has been on the IT market for some time now. New versions have continued to appear, as it is commonly used in projects. But programmers new to Angular mostly think of it only as a Front-End framework, which is not quite the case in reality.]]></description>
										<content:encoded><![CDATA[
<p>I still remember when I started working on my first Angular project, which also included Web Api 2.0 for .NET framework. At the very beginning, of course as a strictly .NET programmer, I was skeptical about it, but I changed my mind really quickly. Below you will find out why.</p>



<p>At the end of this post you will find a simple example of an application built using Angular framework.</p>



<div class="table-of-contents">
    <p class="title">Go To:</p>
    <ol>
                    <li><a href="#what-is-angular">1.  What is angular?</a></li>
                    <li><a href="#how-is-angular-built">2.  How is angular built?</a></li>
                    <li><a href="#controllers">3.  Controllers</a></li>
                    <li><a href="#models">4.  Models</a></li>
                    <li><a href="#views">5.  Views</a></li>
            </ol>
</div>


<h2 class="wp-block-heading" id="what-is-angular">What is Angular?</h2>



<p>In short,&nbsp;<strong>Angular is the framework which allows you to create scalable and very efficient web applications.</strong>&nbsp;Angular is based on JavaScript and HTML.</p>



<h2 class="wp-block-heading" id="how-is-angular-built">How is Angular built?</h2>



<p>And here’s where we get closer to answering the question which is the title of this article.&nbsp;<strong>Version 1.0 of Angular, also known as AngularJS (created for Single Page Applications but also multipage applications), is very similar to MVC (Model-View-Controller).</strong>&nbsp;MVC supports best practices in architecture and writing clean business code and is well-known throughout the IT industry as the ancestor of the architectonic patterns.</p>



<p>Similarly to MVC, the architectonic version of Angular which I mentioned above consists of controllers, models and views. Of course, just as with MVC, we can build web applications in a more complex way, which is also advisable, for example by delegation app logic to the routes, managers and other files – but this is not necessary for understanding similarities to the MVC pattern, which is the aim of this post, after all.</p>



<h2 class="wp-block-heading" id="controllers">Controllers</h2>



<p>The JavaScript controller in Angular, developed within the module, which corresponds to MVC’s controller. The module includes controllers, services and other app files, and is not often declared within the package of functionalities. Personally, when I had to create a functionalities package concerning one domain model, let’s say a package of functionalities concerning displaying data, editing it, a couple of views and communication with APIs, then I would have declared one module.</p>



<p><strong>Better and easier management of the abovementioned modules can be achieved with so-called bundling, which is a mechanism available in JavaScript for managing modules, packages, resources and import/export.</strong></p>



<h2 class="wp-block-heading" id="models">Models</h2>



<p>In AngularJS MVC models have their equivalents, which are also responsible for delivering application logic. In some cases I would say that if Angular is applied for multipage applications purposes, the role of an equivalent of the MVC’s model is played by services, so-called recipes, but for some programmers it can be controversial. Recipes have various types and classes, but in my entire career I’ve never used any of them directly, like so-called&nbsp;<em>value recipes</em>&nbsp;or&nbsp;<em>factory recipes</em>. Instead I use more common&nbsp;<em>service recipes</em>, which can replace the two previously mentioned recipes; most importantly they follow the Constructor Injection design pattern, instead of Singleton. (I hope to write a blog post or series of posts concerning design patterns).</p>



<h2 class="wp-block-heading" id="views">Views</h2>



<p>Similarly to the MVC pattern or any other pattern concerning web applications, we use views responsible for delivering the user interface within our application. In the case of MVC, we mostly use model-type views, which leads to the use of the Razor engine. For those who have not worked with it, the Razor engine, which can be found in ASP.NET MVC from version 3.0, allows users to introduce native objects of a particular language, its syntax and particular model objects into HTML syntax. In the case of Angular, views are mostly created with pure HTML syntax, and the equivalent of the Razor engine’s logic are directives in Angular. Directives are a kind of instructions and procedures – they are “injected” directly into HTML elements.</p>



<p>The most important directives used in Angular are&nbsp;<em>ng-model</em>&nbsp;(passing objects and its values) and&nbsp;<em>ng-repeat</em>&nbsp;(possibility of iterating objects within arrays or lists). One could build plenty of user interfaces using only these two directives.</p>



<p><strong>Below I have given an example of an application based on Angular (not using the service).</strong>&nbsp;You can import the code snippets below into particular code templates available within Web template options in Visual Studio. In the 2017 version, the following may be found:</p>



<ul class="wp-block-list"><li><strong>For Module -&gt;</strong>&nbsp;AngularJs Module</li><li><strong>For controller -&gt;</strong>&nbsp;AngularJs Controller&nbsp;or&nbsp;AngularJs Controller using $scope</li><li><strong>For View -&gt;</strong>&nbsp;standard&nbsp;HTML Page&nbsp;file template</li></ul>



<p><strong>Module:</strong></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">angular.module(‘angularModule’, []);
</pre>



<p><strong>Controller:</strong></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">angular.module(‘angularModule’).controller(“angularController”, function ($scope) {

   $scope.angularTestObject = “test”;

});

View:
&lt;!DOCTYPE html>

&lt;html>

&lt;body>

   &lt;div ng-app=”angularModule” ng-controller=”angularController”>

       &lt;p>angularTestObject’s value equals:&lt;/p>{{ angularTestObject }}

   &lt;/div>

&lt;/body>

&lt;/html></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://nearshore-it.eu/technologies/software-development-angular-for-back-end-programmers-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
