{"id":15362962,"url":"https://github.com/sdd/redux-saga-compose","last_synced_at":"2025-06-12T20:04:07.088Z","repository":{"id":23200824,"uuid":"98410481","full_name":"sdd/redux-saga-compose","owner":"sdd","description":"Middleware composer for redux-saga, in the style of koa-compose","archived":false,"fork":false,"pushed_at":"2023-12-15T05:26:53.000Z","size":14,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-16T15:48:42.795Z","etag":null,"topics":["compose","redux-saga"],"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/sdd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-26T10:22:16.000Z","updated_at":"2022-11-26T12:50:17.000Z","dependencies_parsed_at":"2024-10-16T06:01:26.665Z","dependency_job_id":"4f66e140-14cc-48ee-8edf-de8a5c27c086","html_url":"https://github.com/sdd/redux-saga-compose","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"558f0f4e9a766bf7c1a84e93d98b28b4a82fb9da"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sdd/redux-saga-compose","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdd%2Fredux-saga-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdd%2Fredux-saga-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdd%2Fredux-saga-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdd%2Fredux-saga-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sdd","download_url":"https://codeload.github.com/sdd/redux-saga-compose/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdd%2Fredux-saga-compose/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259521514,"owners_count":22870446,"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","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":["compose","redux-saga"],"created_at":"2024-10-01T13:04:22.290Z","updated_at":"2025-06-12T20:04:07.048Z","avatar_url":"https://github.com/sdd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redux-saga-compose\n\n[![Build Status](https://travis-ci.org/sdd/redux-saga-compose.svg?branch=master)](https://travis-ci.org/sdd/redux-saga-compose)\n\nSmall utility for redux-saga to allow composing of middleware sagas, in the style of koa-compose\n\n## Rationale\n\nFor 95% of sagas, you won't need this. This module is intended for use when redux-saga is used in order to orchestrate a very complex data pipeline.\n\nFor example, you need to:\n\n * take an action, \n * build a complex request object by merging and transforming different bits of the action and state,\n * `put`ting actions pre- and post- request to trigger UI changes,\n * transforming the response from the server (based on more things that you might need from state / originating action),\n * and finally `put` an action containing the response,\n * wrapping the whole lot to catch errors.\n \nThis module allows you to compose sagas that conform to a specific middleware signature (similar to that used by koa's middleware) into a single saga (that is itself composible, should you need to go all inception-style deep).\n\n## Middleware\n\n```javascript\n// the simplest, do nothing, pass-through middleware\nfunction * (request, next) {\n    return (yield call(next, request));\n}\n```\n\n```javascript\nfunction * (request, next) {\n\n   // do something to enrich the request on the way down the middleware stack:\n   const updatedRequest = {\n       ...request,\n       stuff: \"now with added stuff\"\n   };\n   \n   // pass the request down the stack:\n   const response = yield call(next, updatedRequest);\n   \n   // do something to the response on the way back up:\n   return {\n       ...response,\n       thing: \"new improved response with extra thinginess!\"\n   };\n}\n```\n\n## Usage\n\nWe will build a saga that listens for REQUEST_DATA actions and inject them into our middleware pipeline.\n```javascript\n\nimport { takeLatest } from 'redux-saga';\nimport reduxSagaCompose from 'redux-saga-compose';\n\nconst requestPipeline = reduxSagaCompose([\n  \n  // these do things pre-request and post-response, wrapping the whole stack.\n  handleLoadingUI,\n  errorHandlerWrapper,\n  \n  // transforms the request on the way down\n  transformRequest,\n  \n  // transform the response on the way back up (so dispatch happens AFTER transform)\n  dispatchResponseAction,\n  transformResponse,\n  \n  // the u-bend at the bottom of the stack\n  makeRequest\n]);\n\nexport default function * () {\n    yield* takeLatest(REQUEST_DATA, requestPipeline);\n}\n\n```\n\n## More Examples\n\nFor now, check out the tests for implementation. Adding a good example to this Readme is on my todo list :-)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdd%2Fredux-saga-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdd%2Fredux-saga-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdd%2Fredux-saga-compose/lists"}