question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filtering actions by predicate

See original GitHub issue

Currently we seem to have two options for filtering actions - actionsWhitelist and actionsBlacklist - which can handle globs and regular expressions. This allows only for filtering on action types.

It would be very helpful to have a config option like redux-logger’s predicate that allows for more complex filtering based on action payload and/or current state. For example:

predicate: (getState, action) => getState().dev.logLevel === VERBOSE && !action.forwarded

As a workaround (without access to state) I tried something like this:

{
    actionsFilter : action => predicate(action) ? action : {type: 'BLACKLISTED'},
    actionsBlacklist: ['BLACKLISTED']
}

But that didn’t work out. It would seem the execution order is working against me, i.e. the blacklist is applied before the transform.

Perhaps you can think of another workaround?


Alternatively you could use the existing actionsFilter config option and modify it so that it doesn’t log anything when the function returns false. You’d need to pass the state or a getState() function as the third argument to remain backwards compatible. (Personally I’m not a fan of mixed return types though)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
zalmoxisuscommented, Oct 20, 2016

@RIAstar, I’ve implemented the predicate parameter and will publish a new version to Chrome Store tomorrow. Meanwhile, you can amend the changes (especially docs).

0reactions
RIAstarcommented, Oct 24, 2016

Works like a charm. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Predicate Filter Action - Apache Camel
Filter based on a JsonPath Expression. Since this is a filter, the expression will be a negation, this means that if the foo...
Read more >
Filter (Apache Kafka) | Confluent Documentation
You can use predicates in a transformation chain and, when combined with the Apache Kafka® Filter, predicates can conditionally filter out specific records....
Read more >
Java 8 Predicate Chain | Baeldung
Learn different ways to chain Predicates in Java. ... First, let's see how to use a simple Predicate to filter a List of...
Read more >
Filtering redux-form Actions in redux-logger with Predicate ...
I'm attempting to filter @@redux-form/BLUR and the like coming from Redux Form. Log everything except actions with certain type createLogger({  ...
Read more >
Filtering collections | Kotlin Documentation
Filtering is one of the most popular tasks in collection processing. In Kotlin, filtering conditions are defined by predicates – lambda functions that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found