Interview Redux

 What is Redux?

    -    Redux is a library used for managing the state of application.  (or) Manage the application state in a predictable way.


What are benefits?

    - Predictable application state

    - Decoupled architecture

    - Testability

    - Great Tooling

    - Undo/redo

   

When to use Redux?

 - Independent copies of the same data in multiple places

 - Multiple Views need to work with the same data and be in sync.

 - Data can be updated by multiple users

 - Data can be update by multiple actors


What are building block of Redux?

        - Store

        - Actions 

        - Reducers

What is the Store?

 - A Single JS object that contains the state of  the application. (Only one copy of the data is available for entire application. It can be used by different components)

What is the Actions?

    - Actions are Plan JS object that represents something that has happened. (Actions are know Events. For example: postingMessage is an command and MassagePostedEvent is know as Event(Actions).

What is Reducers?

    - A function that specifies how the state changes in the response to an action. A reduce does not modifies the state it only returns the new state.

What is the pure function?

    - If pass the same input and response with the same output without any side effects(no changes) then it is called pure function.

example: function increment (input) {

                    return {count: input.count + 1}; // input.count is not changed it will be same.

                }

Impure function: 

example:  function increment (input) {

                        input.count++;

                }

Reducers require two parameter state & action

function reducer(state, action) {

    switch(action.type) {

        case 'INCREMENT' : 

            return {count : state.count+1} // state not changed.

    }

}

Comments

  1. Online Baccarat - FABCASINO
    It's the only online game that you can play 메리트 카지노 고객센터 online, and you've certainly played it. Now if you're not sure where to 샌즈카지노 play it, then look no further febcasino

    ReplyDelete

Post a Comment

Popular posts from this blog

There is no directive with "exportAs" set to "ngForm" in Angular 2.0 or 4.0

Angular 2.0/4.0 Configuration in Visual Studio