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
- 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
should create a store
- it ensures that Store class is implemented and that it setsstate
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 itshould create a store with initial state and reducers
- the Store is now able to set both initial state (if provided) and reducersshould dispatch an action to a reducer
- the Store should implementdispatch
method that will call a reducer with an action passedshould dispatch an action to all reducers
- the Store should actually dispatch an action to all reducersshould 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 stateshould dispatch an action to reducers and update state immutably
- the Store should not mutate neither the state nor the actionshould notify subscribers on state update
- the Store should implementsubscribe
method that will accept a listener function, that will be called ondispatch
. It also should return unsubscribe function, that (if called) will remove the listener.