Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core.js): pass logEntry to collapsed function #200

Merged
merged 2 commits into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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