Giter VIP home page Giter VIP logo

redux-devtools-instrument's Introduction

Redux DevTools Instrumentation

This package was merged into the redux-devtools monorepo. Please refer to that repository for the latest updates, issues and pull requests.

Redux enhancer used along with Redux DevTools or Remote Redux DevTools.

Installation

npm install --save-dev redux-devtools-instrument

Usage

Add the store enhancer:

store/configureStore.js
import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import devTools from 'remote-redux-devtools';
import reducer from '../reducers';

// Usually you import the reducer from the monitor
// or apply with createDevTools as explained in Redux DevTools
const monitorReducer = (state = {}, action) => state; 

export default function configureStore(initialState) {
  const enhancer = compose(
    applyMiddleware(...middlewares),
    // other enhancers and applyMiddleware should be added before the instrumentation
    instrument(monitorReducer, { maxAge: 50 })
  );
  
  // Note: passing enhancer as last argument requires redux@>=3.1.0
  return createStore(reducer, initialState, enhancer);
}

API

instrument(monitorReducer, [options])

  • arguments
    • monitorReducer function called whenever an action is dispatched (see the example of a monitor reducer).
    • options object
      • maxAge number - maximum allowed actions to be stored on the history tree, the oldest actions are removed once maxAge is reached.
      • shouldCatchErrors boolean - if specified as true, whenever there's an exception in reducers, the monitors will show the error message, and next actions will not be dispatched.
      • shouldRecordChanges boolean - if specified as false, it will not record the changes till pauseRecording(false) is dispatched. Default is true.
      • pauseActionType string - if specified, whenever pauseRecording(false) lifted action is dispatched and there are actions in the history log, will add this action type. If not specified, will commit when paused.
      • shouldStartLocked boolean - if specified as true, it will not allow any non-monitor actions to be dispatched till lockChanges(false) is dispatched. Default is false.
      • shouldHotReload boolean - if set to false, will not recompute the states on hot reloading (or on replacing the reducers). Default to true.

License

MIT

redux-devtools-instrument's People

Contributors

bloodyowl avatar bvaughn avatar chibicode avatar colinmeinke avatar conundrumer avatar danielkcz avatar dzannotti avatar echenley avatar ellbee avatar gaearon avatar hutufairy avatar jasonals avatar kevinrenskers avatar methuselah96 avatar micha149 avatar ngbrown avatar nicinabox avatar nikgraf avatar rickhanlonii avatar robertknight avatar rodrigobacelli avatar rogermarkussen avatar rrrene avatar sapegin avatar sergey-lapin avatar slorber avatar tannerlinsley avatar threepointone avatar yorunohikage avatar zalmoxisus avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.