GithubHelp home page GithubHelp logo

redux's Introduction

README

State Machine

State Machine example uising DFA (Deterministic Finite Automation).

Entries at top first row are inputs, entries at the left first column are the states.

AaaToBbbAction BbbToCccAction BbbToFinalAction CccToFinalAction Others
AaaState BbbState AaaState AaaState AaaState AaaState
BbbState BbbState CccState FinalState BbbState BbbState
CccState CccState CccState CccState FinalState CccState
FinalState FinalState FinalState FinalState FinalState FinalState

Pros

  • Better for Event Driven Design - one action / event might have multiple different handlers in different components.
  • Extensible - adding one State doesn't impact the other states.
  • Handler mapping to each dispatched action/event is managed by the state machine itself; There is no necessary for Action/Event issuer to understand the which action/handler method to call explicitly

Cons

  • Based on the Action / Event name to find the corresponding handler defined in state, switch-case is unpreventable.
  • Types of payload are unknown to the handler, runtime inference is required.

Another implementation of State (Machine) Pattern.

Pros

  • Switch-case is prevented
  • The types of payload for each action handler is clearly defined.

Cons

  • Adding one action for one state will impact all the other states.
  • Switch-case is still required before calling the handler function inside the action if Even-Driven design is used by the system.
  • Needs to understand which action/handler method to call at each step.

Redux

Java version of Redux implementation.

newState = reducer.reduce(currentState, payload).

Popular in React JS.

another

Let’s learn how modern JavaScript frameworks work by building one

redux's People

Contributors

damonyuan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.