Skip to content

Commit

Permalink
feat: pass logEntry to collapsed function (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 authored and imevro committed Feb 1, 2017
1 parent 8c916d0 commit cae12d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ on error" in dev tools harder to use, as it breaks on re-throw rather than the o

*Default: `true`*

#### __collapsed = (getState: Function, action: Object) => Boolean__
#### __collapsed = (getState: Function, action: Object, logEntry: Object) => Boolean__
Takes a boolean or optionally a function that receives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if the log group should be collapsed, `false` otherwise.

*Default: `false`*
Expand Down Expand Up @@ -202,6 +202,13 @@ createLogger({
});
```

### Collapse actions that don't have errors
```javascript
createLogger({
collapsed: (getState, action, logEntry) => !logEntry.error
});
```

### Transform Immutable (without `combineReducers`)
```javascript
import { Iterable } from 'immutable';
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function printBuffer(buffer, options) {

// Message
const formattedAction = actionTransformer(action);
const isCollapsed = (typeof collapsed === `function`) ? collapsed(() => nextState, action) : collapsed;
const isCollapsed = (typeof collapsed === `function`) ? collapsed(() => nextState, action, logEntry) : collapsed;

const formattedTime = formatTime(startedTime);
const titleCSS = colors.title ? `color: ${colors.title(formattedAction)};` : null;
Expand Down

0 comments on commit cae12d8

Please sign in to comment.