Gathering detailed insights and metrics for redux-thunk-recursion-detect
Gathering detailed insights and metrics for redux-thunk-recursion-detect
Gathering detailed insights and metrics for redux-thunk-recursion-detect
Gathering detailed insights and metrics for redux-thunk-recursion-detect
A collection of tools for building Redux applications in a thunk-centric fashion.
npm install redux-thunk-recursion-detect
Typescript
Module System
Node Version
NPM Version
JavaScript (95.49%)
HTML (1.75%)
CSS (1.49%)
TypeScript (1.28%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
21 Stars
104 Commits
10 Forks
3 Watchers
152 Branches
1 Contributors
Updated on May 23, 2024
Latest Version
1.1.4
Package Id
redux-thunk-recursion-detect@1.1.4
Unpacked Size
10.58 kB
Size
3.57 kB
File Count
6
NPM Version
lerna/3.19.0/node@v12.13.0+x64 (darwin)
Node Version
12.13.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A drop-in replacement for redux-thunk
that allows other middleware to detect that a thunk has been dispatched from within another thunk.
Ah, yes, a very good question. I wish the answer was "you don't ever have to" and this middleware didn't need to exist. However, there exist some edge cases, (error handling being one of them) where knowing that you're at the top of the redux dispatch
call stack is important.
I wrote an explanation that helps understand one such case in redux-thunk-error-handler's thunkErrorHandling.md
1npm install redux-thunk-recursion-detect
Normally, you can just replace anywhere you're using redux-thunk
with this library instead.
1import { createStore, applyMiddleware } from 'redux'; 2import thunkMiddleware from 'redux-thunk-recursion-detect'; 3 4const store = createStore(myReducerFn, applyMiddleware(thunkMiddleware));
Then, in some other middleware that needs to know whether or not a thunk was dispatched from inside another thunk, you can use the isNestedThunkSymbol
export to test for it.
1import { isNestedThunkSymbol } from 'redux-thunk-recursion-detect'; 2 3export const myCoolMiddleware = store => next => action => { 4 if (typeof action === 'function' && action[isNestedThunkSymbol]) { 5 // The thunk that is currently in the dispatch pipeline is a nested thunk. 6 doWhateverINeedForNestedThunks(); 7 return next(action); 8 } else { 9 // The thunk is at the top level of its call stack 10 return next(action) 11 } 12}
Take a look at redux-thunk-error-handler to see a real application of this middleware.
This library is part of a larger set of tools that can be helpful for making thunk-centric Redux applications. Visit that project to see a runnable example app that makes use of this code in context.
Copyright (c) 2015-2018 Ian Taylor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/12 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
162 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More