redux-devtools-instrument
Advanced tools
Comparing version 1.9.1 to 1.9.2
@@ -306,2 +306,6 @@ 'use strict'; | ||
// maxAge number can be changed dynamically | ||
var maxAge = options.maxAge; | ||
if (typeof maxAge === 'function') maxAge = maxAge(liftedAction); | ||
if (/^@@redux\/(INIT|REPLACE)/.test(liftedAction.type)) { | ||
@@ -321,7 +325,7 @@ if (options.shouldHotReload === false) { | ||
if (options.maxAge && stagedActionIds.length > options.maxAge) { | ||
if (maxAge && stagedActionIds.length > maxAge) { | ||
// States must be recomputed before committing excess. | ||
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, options.shouldCatchErrors); | ||
commitExcessActions(stagedActionIds.length - options.maxAge); | ||
commitExcessActions(stagedActionIds.length - maxAge); | ||
@@ -339,4 +343,4 @@ // Avoid double computation. | ||
// Auto-commit as new actions come in. | ||
if (options.maxAge && stagedActionIds.length === options.maxAge) { | ||
commitExcessActions(1); | ||
if (maxAge && stagedActionIds.length >= maxAge) { | ||
commitExcessActions(stagedActionIds.length - maxAge + 1); | ||
} | ||
@@ -651,5 +655,3 @@ | ||
/* eslint-disable no-eq-null */ | ||
if (options.maxAge != null && options.maxAge < 2) { | ||
/* eslint-enable */ | ||
if (typeof options.maxAge === 'number' && options.maxAge < 2) { | ||
throw new Error('DevTools.instrument({ maxAge }) option, if specified, ' + 'may not be less than 2.'); | ||
@@ -656,0 +658,0 @@ } |
{ | ||
"name": "redux-devtools-instrument", | ||
"version": "1.9.1", | ||
"version": "1.9.2", | ||
"description": "Redux DevTools instrumentation", | ||
@@ -5,0 +5,0 @@ "main": "lib/instrument.js", |
@@ -47,3 +47,3 @@ Redux DevTools Instrumentation | ||
- **options** *object* | ||
- **maxAge** *number* - maximum allowed actions to be stored on the history tree, the oldest actions are removed once `maxAge` is reached. | ||
- **maxAge** *number* or *function* - maximum allowed actions to be stored on the history tree, the oldest actions are removed once `maxAge` is reached. Can be generated dynamically with a function getting current action as argument. | ||
- **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. | ||
@@ -50,0 +50,0 @@ - **shouldRecordChanges** *boolean* - if specified as `false`, it will not record the changes till `pauseRecording(false)` is dispatched. Default is `true`. |
@@ -312,2 +312,6 @@ import difference from 'lodash/difference'; | ||
// maxAge number can be changed dynamically | ||
let maxAge = options.maxAge; | ||
if (typeof maxAge === 'function') maxAge = maxAge(liftedAction); | ||
if (/^@@redux\/(INIT|REPLACE)/.test(liftedAction.type)) { | ||
@@ -328,3 +332,3 @@ if (options.shouldHotReload === false) { | ||
if (options.maxAge && stagedActionIds.length > options.maxAge) { | ||
if (maxAge && stagedActionIds.length > maxAge) { | ||
// States must be recomputed before committing excess. | ||
@@ -342,3 +346,3 @@ computedStates = recomputeStates( | ||
commitExcessActions(stagedActionIds.length - options.maxAge); | ||
commitExcessActions(stagedActionIds.length - maxAge); | ||
@@ -355,4 +359,4 @@ // Avoid double computation. | ||
// Auto-commit as new actions come in. | ||
if (options.maxAge && stagedActionIds.length === options.maxAge) { | ||
commitExcessActions(1); | ||
if (maxAge && stagedActionIds.length >= maxAge) { | ||
commitExcessActions(stagedActionIds.length - maxAge + 1); | ||
} | ||
@@ -651,5 +655,3 @@ | ||
export default function instrument(monitorReducer = () => null, options = {}) { | ||
/* eslint-disable no-eq-null */ | ||
if (options.maxAge != null && options.maxAge < 2) { | ||
/* eslint-enable */ | ||
if (typeof options.maxAge === 'number' && options.maxAge < 2) { | ||
throw new Error( | ||
@@ -656,0 +658,0 @@ 'DevTools.instrument({ maxAge }) option, if specified, ' + |
52182
1221