Giter Club home page Giter Club logo

redux-store's Introduction

Redux store implementation

A simple Redux store implementation in vanilla JS, tailored for a workshop. This repository gives you a set of tests that ensure basic functionality of Redux Store is implemented.

At its core, Redux is really a fairly simple design pattern: all your "write" logic goes into a single function, and the only way to run that logic is to give Redux a plain object that describes something that has happened. The Redux store calls that write logic function and passes in the current state tree and the descriptive object, the write logic function returns some new state tree, and the Redux store notifies any subscribers that the state tree has changed. - Redux page

Preliminaries

  • Clone the repository
  • Install Node v8.9.4 (LTS)
  • Run npm install in the project directory so that all dependencies are installed
  • Run npm test to run tests for the store and check if your implementation is correct

Test Cases

  • should create a store - it ensures that Store class is implemented and that it sets state property to some default value (e.g. empty object)
  • should create a store with some initial state - the Store is extended, it allows passing initial state and stores it
  • should create a store with initial state and reducers - the Store is now able to set both initial state (if provided) and reducers
  • should dispatch an action to a reducer - the Store should implement dispatch method that will call a reducer with an action passed
  • should dispatch an action to all reducers - the Store should actually dispatch an action to all reducers
  • should dispatch an action to reducers and update state - the Store dispatch method should build a new state based on return values of all reducers and update the current state
  • should dispatch an action to reducers and update state immutably - the Store should not mutate neither the state nor the action
  • should notify subscribers on state update - the Store should implement subscribe method that will accept a listener function, that will be called on dispatch. It also should return unsubscribe function, that (if called) will remove the listener.

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.