AngularJS 2.0 From The Beginning

#AngularJS 2.0 From The Beginning - #ImmutableJS - Day 22 cc @debasiskolsaha @CsharpCorner

  • In this case however, changing the value of an episode on one object has also changed the value of the other.
  • This is especially true when your Application can execute code asynchronously.
  • After it’s completed, you notice the state; it’s expecting changed because some other piece of code executed asynchronously and changed its value.
  • Immutability attempts to solve this by making sure that any object referenced in one part of the code can’t be changed by another part of the code unless they have the ability to rebind it directly.
  • We can use this to copy an object’s value without altering the existing one.

In this article, we will discuss about Immutable js.

@CsharpCorner: #AngularJS 2.0 From The Beginning – #ImmutableJS – Day 22 cc @debasiskolsaha @CsharpCorner

Immutable.js is a library, which provides immutable generic collections.

One of the more difficult things to manage when structuring an Application is managing its state. This is especially true when your Application can execute code asynchronously. Let’s say you execute some piece of code, but something causes it to wait (such as an HTTP request or a user input). After it’s completed, you notice the state; it’s expecting changed because some other piece of code executed asynchronously and changed its value.

Dealing with this kind of behavior on a small scale might be manageable, but this can show up all over an Application and can be a real headache as the Application gets bigger with more interactions and more complex logic. Immutability attempts to solve this by making sure that any object referenced in one part of the code can’t be changed by another part of the code unless they have the ability to rebind it directly.

To solve our mutability problem, Immutable.js must provide immutable versions of the two core mutable types i.e. Object and Array.

AngularJS 2.0 From The Beginning

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.