{"id":18327611,"url":"https://github.com/angular-redux/redux-observable-decorator","last_synced_at":"2025-04-06T01:32:05.622Z","repository":{"id":57351141,"uuid":"77006866","full_name":"angular-redux/redux-observable-decorator","owner":"angular-redux","description":"Decorators for Redux Observable","archived":false,"fork":false,"pushed_at":"2019-01-16T04:21:39.000Z","size":142,"stargazers_count":13,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-21T15:10:59.704Z","etag":null,"topics":["observable","redux","redux-observable","rxjs"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/angular-redux.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.MD","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-21T02:01:10.000Z","updated_at":"2020-03-24T09:57:54.000Z","dependencies_parsed_at":"2022-09-19T13:02:01.040Z","dependency_job_id":null,"html_url":"https://github.com/angular-redux/redux-observable-decorator","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angular-redux%2Fredux-observable-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angular-redux%2Fredux-observable-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angular-redux%2Fredux-observable-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angular-redux%2Fredux-observable-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angular-redux","download_url":"https://codeload.github.com/angular-redux/redux-observable-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423475,"owners_count":20936621,"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":["observable","redux","redux-observable","rxjs"],"created_at":"2024-11-05T19:11:36.440Z","updated_at":"2025-04-06T01:32:04.581Z","avatar_url":"https://github.com/angular-redux.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/angular-redux/redux-observable-decorator/tree/master.svg?style=svg)](https://circleci.com/gh/angular-redux/redux-observable-decorator/tree/master)\n[![npm version](https://img.shields.io/npm/v/redux-observable-decorator.svg)](https://www.npmjs.com/package/redux-observable-decorator)\n[![npm downloads](https://img.shields.io/npm/dt/redux-observable-decorator.svg)](https://www.npmjs.com/package/redux-observable-decorator)\n\n# redux-observable-decorator\n\nDecorators for Redux Observable\n\nWhen using Redux with Angular with __angular-redux/store__ and __redux-observable__, it's common to create your epics as an injectable class, and when configuring the store - creating an epic middleware for each one, or using `combineEpics`:\n\n```ts\n@Injectable()\nexport class SomeEpics {\n\tepicOne = (action$) =\u003e action$.ofType('PING').pipe(mapTo({type: 'PONG'}));\n\tepicTwo = (action$) =\u003e action$.ofType('ACTION_IN').pipe(mapTo({type: 'ACTION_OUT'}));\n}\n\n@NgModule({\n\n})\nexport class AppModule {\n\tconstructor(ngRedux: NgRedux, someEpics: SomeEpics) {\n\t\tlet epics = combineEpics(\n\t\t\tsomeEpics.epicOne,\n\t\t\tsomeEpics.epicTwo\n\t\t);\n\t\tlet epicMiddleware = createEpicMidleware();\n\n\t\tngRedux.configureStore(reducer,[epicMiddleware]);\n\t\tepicMiddleware.run(epics);\n\n\t\t// or\n\n\t\tlet epicOne = createMiddleware(someEpics.epicOne);\n\t\tlet epicTwo = createMiddleware(someEpics.epicTwo);\n\n\t\tngRedux.configureStore(reducer,[epicOne, epicTwo]);\n\t}\n}\n```\n\nThis decorator is intended to make it easier to mark which properties / methods in a class are Epics to simplify creating the epic middleware for your application.\n\n```ts\nimport { Epic } from 'redux-observable-decorator';\n\n@Injectable()\nexport class SomeEpics {\n\t@Epic() epicOne = (action$) =\u003e action$.ofType('PING').pipe(mapTo({type: 'PONG'}));\n\t@Epic() epicTwo = (action$) =\u003e action$.ofType('ACTION_IN').pipe(mapTo({type: 'ACTION_OUT'}));\n}\n```\n\n```ts\nimport { combineDecoratedEpics } from 'redux-observable-decorator';\nimport { createEpicMiddleware } from 'redux-observable';\n\n@NgModule({\n\n})\nexport class AppModule {\n\tconstructor(ngRedux:NgRedux, someEpics:SomeEpics) {\n\t\tlet epics = combineDecoratedEpics(someEpics);\n\t\tconst epicMiddleware = createEpicMiddleware();\n\n\t\tngRedux.configureStore(reducer,[epicMiddleware]);\n\t\tepicMiddleware.run(epics);\n\t}\n}\n```\n\nThis can be used with vanilla redux also - as seen in the unit tests...\n\n```ts\nclass Test {\n\t@Epic() epic = (action$) =\u003e action$.ofType('TEST_IN').pipe(mapTo({ type: 'TEST_OUT' }));\n}\n\nconst reducer = (state = [], action) =\u003e state.concat(action);\nconst epics = new Test();\nconst epicMiddleware = createEpicMiddleware(epics);\nconst store = createStore(reducer, applyMiddleware(epicMiddleware));\nepicMiddleware.run(combineDecoratedEpics(epics));\n```\n\n# Inspiration\n\nThe `@Effect` decorator from [ngrx/effects](https://github.com/ngrx/effects)\n\n# Todo\n\n* [ ] Better docs\n* [ ] Publish on NPM\n* [ ] Improve tests\n* [ ] Get test coverage working\n* [ ] Some Anglar 2 / integration tests\n* [ ] Example App\n* [ ] Strategy for lazy loading epics (to support code-splitting)?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangular-redux%2Fredux-observable-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangular-redux%2Fredux-observable-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangular-redux%2Fredux-observable-decorator/lists"}