{"id":18544600,"url":"https://github.com/instructure/service-middleware","last_synced_at":"2025-05-15T05:34:12.804Z","repository":{"id":44001684,"uuid":"237532507","full_name":"instructure/service-middleware","owner":"instructure","description":"ITSD-63375","archived":false,"fork":false,"pushed_at":"2023-07-18T20:49:50.000Z","size":1708,"stargazers_count":0,"open_issues_count":15,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-02-17T09:16:21.499Z","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/instructure.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,"zenodo":null}},"created_at":"2020-01-31T23:17:18.000Z","updated_at":"2020-02-05T18:48:10.000Z","dependencies_parsed_at":"2023-02-03T15:46:20.944Z","dependency_job_id":"1454332f-948a-4953-a016-cf9067630067","html_url":"https://github.com/instructure/service-middleware","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fservice-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fservice-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fservice-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fservice-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/instructure","download_url":"https://codeload.github.com/instructure/service-middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254282437,"owners_count":22045123,"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":[],"created_at":"2024-11-06T20:17:03.420Z","updated_at":"2025-05-15T05:34:12.777Z","avatar_url":"https://github.com/instructure.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @instructure/redux-service-middleware\n\n[![npm](https://img.shields.io/npm/v/@instructure/redux-service-middleware.svg)](https://www.npmjs.com/package/@instructure/redux-service-middleware)\n[![MIT License](https://img.shields.io/npm/l/@instructure/redux-service-middleware.svg?style=flat-square)](https://github.com/instructure/redux-service-middleware/blob/master/LICENSE)\n\nSimple [redux](https://redux.js.org/) [middleware](https://redux.js.org/advanced/middleware/) for registering service objects.\n\n1. A service is an object or class instance:\n\n```javascript\nconst myService = {\n  doStuff: (arg1, arg2) =\u003e result\n}\nclass MyOtherService {\n  doOtherStuff (...args) {\n    return result\n  }\n}\n```\n\n2. While creating your store, register your services as key/value pairs\n   with the service middleware constructor:\n\n```javascript\nimport { applyMiddleware } from 'redux'\nimport createServiceMiddleware from '@instructure/redux-service-middleware'\n\napplyMiddleware(\n  createServiceMiddleware({\n    myKey: myService,\n    myOtherKey: new MyOtherService()\n  })\n)\n```\n\n3. In your action creator, dispatch an action with the following shape:\n\n```javascript\nimport { CALL_SERVICE } from '@instructure/redux-service-middleware'\n\nconst actionCreator = () =\u003e ({\n  type: CALL_SERVICE,\n  payload: {\n    service: 'myKey',\n    method: 'doStuff',\n    args: [arg1, arg2]\n  }\n})\n```\n\nCalls to `dispatch` with an action of this form will return a promise\nresolving to the result of calling\n`myService.methodName(arg1, arg2)`.\n\n## License\n\nThis project is is released under the [MIT](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstructure%2Fservice-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finstructure%2Fservice-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstructure%2Fservice-middleware/lists"}