{"id":21190101,"url":"https://github.com/reactiumcore/redux-super-thunk","last_synced_at":"2026-07-17T11:32:24.679Z","repository":{"id":47975882,"uuid":"117983423","full_name":"ReactiumCore/redux-super-thunk","owner":"ReactiumCore","description":"Redux middleware that returns a function instead of an action but with a twist. ","archived":false,"fork":false,"pushed_at":"2023-01-07T04:01:15.000Z","size":665,"stargazers_count":1,"open_issues_count":7,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-01T12:11:20.362Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ReactiumCore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-18T13:00:50.000Z","updated_at":"2021-05-11T22:13:16.000Z","dependencies_parsed_at":"2023-02-06T11:16:24.429Z","dependency_job_id":null,"html_url":"https://github.com/ReactiumCore/redux-super-thunk","commit_stats":null,"previous_names":["reactiumcore/redux-super-thunk","atomic-reactor/redux-super-thunk"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ReactiumCore/redux-super-thunk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiumCore%2Fredux-super-thunk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiumCore%2Fredux-super-thunk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiumCore%2Fredux-super-thunk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiumCore%2Fredux-super-thunk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReactiumCore","download_url":"https://codeload.github.com/ReactiumCore/redux-super-thunk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiumCore%2Fredux-super-thunk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280832994,"owners_count":26398969,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T18:59:25.970Z","updated_at":"2025-10-24T17:07:55.452Z","avatar_url":"https://github.com/ReactiumCore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Redux Super Thunk\n=================\n\nThunk [middleware](http://redux.js.org/docs/advanced/Middleware.html) for Redux that adds the store as an argument.\n\n```bash\nnpm install --save redux-super-thunk\n```\n\n# Apply Middleware\n\nTo use redux super thunk, you will need to use the super thunk version of the `applyMiddleware` enhancer, instead of the out of the box version from the redux library.\n\n```js\nimport { createStore, combineReducers } from 'redux'\nimport thunk, { applyMiddleware } from 'redux-super-thunk';\nimport * as reducers from './reducers'\n\nlet reducer = combineReducers(reducers)\n\n// using super thunk applyMiddleware instead of\n// the one from redux library\nlet store = createStore(reducer, applyMiddleware(thunk))\n```\n\n\n# Why Redux Super Thunk?\nRedux Super Thunk is a super-set of what is provided by [Redux Thunk](https://github.com/gaearon/redux-thunk). Redux Thunk supplies the redux store's `dispatch` and `getState` methods to a higher-order action creator (as well as an addition argument of your choosing).\n\nWhile thunk is a powerful too for being able to create almost any manner of asynchronous actions, it would be so much more powerful to supply the `store` as well, making it possible to subscribe to a store inside of a higher order action creator. This is where Super Thunk comes in.\n\n```js\nimport axios from 'axios';\n\nexport default {\n    subscribe: params =\u003e (dispatch, getState, store) =\u003e {\n        let unsubscribe = store.subscribe(() =\u003e {\n            let ival = setInterval(() =\u003e {\n                let state = getState()['subscription'];\n                if ( state === 'on' ) {\n                     axios.get('http://someapi/my-data').then((result) =\u003e {\n                        dispatch({ type: 'MY_UPDATE', result: result});                \n                    });\n                }\n                else {\n                    clearInterval(ival);\n                    unsubscribe();\n                }\n            }, 8000);\n        });\n    },\n\n    unsubscribe: () =\u003e ({type: 'UNSUBSCRIBE'}),\n};\n```\n\n## Super Thunk with extra argument\n\nFor redux thunk users that are currently using an extra argument when adding thunk as middleware, you can still do this, and the store becomes a fourth argument for your thunk action creator.\n\nSetup with extra argument:\n```js\nimport { createStore, combineReducers } from 'redux'\nimport thunk, { applyMiddleware } from 'redux-super-thunk';\nimport * as reducers from './reducers'\nimport axios from 'axios';\n\nlet reducer = combineReducers(reducers)\n\nconst api = axios.create({ baseUrl: 'http://someapi' });\nlet store = createStore(reducer, applyMiddleware(thunk.withExtraArgument(api)))\n```\n\nYour thunk will now be:\n```js\nexport default {\n    subscribe: params =\u003e (dispatch, getState, api, store) =\u003e {\n        let unsubscribe = store.subscribe(() =\u003e {\n            let ival = setInterval(() =\u003e {\n                let state = getState()['subscription'];\n                if ( state === 'on' ) {\n                     api.get('/my-data').then((result) =\u003e {\n                        dispatch({ type: 'MY_UPDATE', result: result});                \n                    });\n                }\n                else {\n                    clearInterval(ival);\n                    unsubscribe();\n                }\n            }, 8000);\n        });\n    },\n\n    unsubscribe: () =\u003e ({type: 'UNSUBSCRIBE'}),\n};\n```\n\n**_For more information on thunks go [here](https://github.com/gaearon/redux-thunk)_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactiumcore%2Fredux-super-thunk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freactiumcore%2Fredux-super-thunk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactiumcore%2Fredux-super-thunk/lists"}