<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: nishathapa</title>
    <description>The latest articles on Forem by nishathapa (@nishathapa).</description>
    <link>https://forem.com/nishathapa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F401696%2F6002045a-656d-4636-b7fd-4306a0563164.jpeg</url>
      <title>Forem: nishathapa</title>
      <link>https://forem.com/nishathapa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nishathapa"/>
    <language>en</language>
    <item>
      <title>Flux Architecture</title>
      <dc:creator>nishathapa</dc:creator>
      <pubDate>Tue, 15 Jun 2021 09:05:51 +0000</pubDate>
      <link>https://forem.com/nishathapa/flux-architecture-1mdl</link>
      <guid>https://forem.com/nishathapa/flux-architecture-1mdl</guid>
      <description>&lt;p&gt;Flux Architecture in ReactJs&lt;/p&gt;

&lt;p&gt;What is ReactJs&lt;br&gt;
ReactJs is JavaScript Framework which was originated and first used by Facebook for building SPAs. The motive of ReactJs was to improve its UI which is very complex and also change with time. &lt;br&gt;
Normally in web development, MVC architecture is used, but the concept of ReactJs is entirely different because first its not a general purpose architecture and second it was made to actually solve the complexity problem faced with Facebook. ReactJs was majorly developed to deal with large data set which change over time using unidirectional data flow structure i.e flux architecture. Flux is a new kind of architecture follows the concept of unidirectional flow model. Flux has an advantage when using huge data and also if the data needs to be updated timely in an effective manner&lt;/p&gt;

&lt;p&gt;Pros of Flux:  &lt;a href="https://stackshare.io/flux" rel="noopener noreferrer"&gt;https://stackshare.io/flux&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Unidirectional flow&lt;/li&gt;
&lt;li&gt;Architecture&lt;/li&gt;
&lt;li&gt;Structure and Data flow&lt;/li&gt;
&lt;li&gt;Not MVC&lt;/li&gt;
&lt;li&gt;Open source&lt;/li&gt;
&lt;li&gt;Created by Facebook&lt;/li&gt;
&lt;li&gt;A gestalt shift&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;According to Flux architecture the application is split into these following components:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F40vnh2m8ex4l9nv5pjqz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F40vnh2m8ex4l9nv5pjqz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Actions: Action is that component of architecture where the user interacts with the application. Action contains all the information that is needed to that particular action. It has a type property that identifies the action type and helps in passing data to the dispatcher.&lt;/p&gt;

&lt;p&gt;Dispatcher:There is always only one dispatcher that is called the global dispatcher. This dispatcher broadcasts all the actions and events to the registered stores. When the user click the send button an action is generated via dispatcher. when action comes in, it will pass the it to the stores. Basically dispatcher is the manager of the whole process. It takes actions and broadcasts it to all the stores so as to update the states of the view.&lt;/p&gt;

&lt;p&gt;Stores: Store contains the logic. It contains the model. It stores user interface states which can be later retrieved by passing an action to the dispatcher. It also stores the domain state. &lt;br&gt;
The function of store is to listen to the actions and then act on them accordingly which means that it'll have a switch statement.A switch statement is used to interpret the action and invoke a proper callback. Once the state changes is configured, it emits a change event, and then view layer of the application is updated. &lt;/p&gt;

&lt;p&gt;Controller Views: Controller view is the user interface component which handles the view part of the application. It is that component of application where the data is rendered. It is responsible for handling al the events based on the user. They may contain some containers which basically connects the action and dispatcher or presentation view which are not connected to the actions and dispatchers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9pohtfmlggjzb9vbpiyq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9pohtfmlggjzb9vbpiyq.png" alt="www.oreilly.com"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So from this basic flux architecture we can conclude that when the user clicks a send button from the controller view component, the user is basically calling the action. This action is passed to the dispatcher and the dispatcher passes it to the store. The store updates the controller view layer and then the cycle goes on. &lt;br&gt;
Hence we can say that the flux architecture is simple and updates the view layer of the application with the latest version of data timely.&lt;/p&gt;

&lt;p&gt;Some alternatives to FLUX:&lt;br&gt;
Flow: Flow is an online collaboration platform that makes it easy for people to create, organize, discuss, and accomplish tasks with anyone, anytime, anywhere. &lt;/p&gt;

&lt;p&gt;Mono: It is a software platform designed to allow developers to easily create cross platform applications part of the .NET Foundation. It is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime.&lt;/p&gt;

&lt;p&gt;jQuery: jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML.&lt;/p&gt;

&lt;p&gt;React: Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it's easy to try it out on a small feature in an existing project.&lt;/p&gt;

&lt;p&gt;AngularJs: AngularJS lets you write client-side web applications as if you had a smarter browser. It lets you use good old HTML (or HAML, Jade and friends!) as your template language and lets you extend HTML’s syntax to express your application’s components clearly and succinctly. It automatically synchronizes data from your UI (view) with your JavaScript objects (model) through 2-way data binding.&lt;/p&gt;

</description>
      <category>redux</category>
      <category>react</category>
      <category>angular</category>
      <category>webdev</category>
    </item>
    <item>
      <title>A Quick Guide to AJAX</title>
      <dc:creator>nishathapa</dc:creator>
      <pubDate>Mon, 23 Nov 2020 16:47:58 +0000</pubDate>
      <link>https://forem.com/nishathapa/a-quick-guide-to-ajax-480e</link>
      <guid>https://forem.com/nishathapa/a-quick-guide-to-ajax-480e</guid>
      <description>&lt;p&gt;This is a small reference for all the developers who are new to AJAX.&lt;/p&gt;

&lt;p&gt;Full form of &lt;strong&gt;AJAX&lt;/strong&gt; is &lt;strong&gt;Asynchronous JavaScript and XML&lt;/strong&gt;. (XML is commonly used as the format for receiving server data, although any format, including plain text, can be used ). AJAX is no programming language but a mix of few concepts. It is a new technique for creating better, faster and more interactive web applications with the help of XML, HTML, CSS and JavaScript.&lt;/p&gt;

&lt;p&gt;AJAX was coined in 2005 by Jesse James Garrett, that describes a “new” approach to using a number of existing technologies together, including HTML or XHTML, CSS, JavaScript, DOM, XML, and most importantly the &lt;strong&gt;XMLHttpRequest&lt;/strong&gt; object. It is a client-side script that communicates to and from a sever without reloading or refreshing the webpage again and again. You just need to request data from server, when the server receives the data, it sends the data back to your webpage. The sending of the data basically works in the background which means that With AJAX, when you hit submit, JavaScript will make a request to the server, interpret the results, update the current screen and the user would never know that anything was even transmitted to the server.&lt;/p&gt;

&lt;p&gt;Definition : &lt;strong&gt;“The method of exchanging data with a server, and updating parts of a web page — without reloading the entire page.”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript includes features of sending asynchronous http request using XMLHttpRequest object. Ajax is about using this ability of JavaScript to send asynchronous http request and get the xml data as a response (also in other formats like JSON ) and update the part of a web page (using JavaScript) without reloading or refreshing entire web page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Ajax:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Callbacks:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ajax is used to perform a callback, making a quick round trip to and from the server to retrieve and/or save data without posting the entire page back to the server. It only sends the data to the sever that is necessary, this way it minimizes the network utilization and the operations are performed faster. By using callbacks the server is not required to process all the data hence there is limited data processing on the server.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Asynchronous calls:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ajax allows you to make asynchronous calls to a web server. This allows the client browser to avoid waiting for all data to arrive before allowing the user to act once more.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;User-friendly:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Because a page postback is being eliminated, Ajax enabled applications will always be more responsive, faster and more user-friendly.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Increased speed:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The most important usage of AJAX is to improve the speed, performance and usability of web application. For instance, if we look at the example of Netflix, the ratings and preference of movies are stored in your database and for the particular function, the complete webpage is not reloaded instead only that particular block of rating is refreshed. This save time and also improves the usability of the application.&lt;/p&gt;

&lt;p&gt;AJAX cannot work independently. It is used in combination with other technologies to create webpages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Javascript:&lt;/strong&gt; JavaScript is a loosely typed scripting language. The JavaScript functions are called when an event occurs in a page.It works as a glue for the whole AJAX operation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DOM:&lt;/strong&gt; Dom represents the structure of XML and HTML documents. It uses API for accessing and manipulating structured documents.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CSS:&lt;/strong&gt; CSS allows for a clear separation of the presentation style from the content and may be changed programmatically by JavaScript&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;XMLHttpRequest:&lt;/strong&gt; JavaScript object that performs asynchronous interaction with the&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Steps of AJAX Operation&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A client event occurs.&lt;/li&gt;
&lt;li&gt;An XMLHttpRequest object is created.&lt;/li&gt;
&lt;li&gt;The XMLHttpRequest object is configured.&lt;/li&gt;
&lt;li&gt;The XMLHttpRequest object makes an asynchronous request to the Web-server.&lt;/li&gt;
&lt;li&gt;The Web-server returns the result containing XML document.&lt;/li&gt;
&lt;li&gt;The XMLHttpRequest object calls the callback() function and processes the result.&lt;/li&gt;
&lt;li&gt;The HTML DOM is updated.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Advances made to AJAX&lt;/strong&gt;&lt;br&gt;
JavaScript is the client-side programming language and XML is a markup language to define data. The fetched data from the server is in XML, but now JSON ( Another markup language to define data) web services are replacing the XML Web services since JSON is much easier to read and use with JavaScript.&lt;/p&gt;

&lt;p&gt;Another advance is the JavaScript Object Library called JQuery. JQuery is an free, opensource software. It is used to easily write client-side JavaScript to navigate and manipulate a page and make asynchronous Ajax callbacks.&lt;/p&gt;

&lt;p&gt;The Ajax Control Toolkit is a suite of controls created by Microsoft that is integrated into Visual Studio and can be dragged and dropped onto web forms just like HTML and server controls. These controls are intended to be used for Ajax callbacks. However, they can also be used as normal client and or server controls. For example, Asp.Net does not come with the Tabs controls. However, the Ajax Control Toolkit does. The Tab control can postback to the server just like server controls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rich Internet Application Technology:&lt;/strong&gt; AJAX is the most viable Rich Internet Application (RIA) technology so far. It is getting tremendous industry momentum and several tool kit and frameworks are emerging. But at the same time, AJAX has browser incompatibility and it is supported by JavaScript, which is hard to maintain and debug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Browser Support&lt;/strong&gt;&lt;br&gt;
Not all browsers support AJAX. This means that the particular browser does not support the creation of JavaScript object — XMLHttpRequest object. Few browsers that support AJAX are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Mozilla Firefox 1.0 and above.&lt;/li&gt;
&lt;li&gt;Netscape version 7.1 and above.&lt;/li&gt;
&lt;li&gt;Apple Safari 1.2 and above.&lt;/li&gt;
&lt;li&gt;Microsoft Internet Explorer 5 and above.&lt;/li&gt;
&lt;li&gt;Konqueror.&lt;/li&gt;
&lt;li&gt;Opera 7.6 and above&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>react</category>
      <category>ajax</category>
      <category>javascript</category>
      <category>jquery</category>
    </item>
  </channel>
</rss>
