{"id":26432296,"url":"https://github.com/adamlewkowicz/reduxio","last_synced_at":"2026-05-02T11:31:53.725Z","repository":{"id":44143748,"uuid":"185243537","full_name":"adamlewkowicz/reduxio","owner":"adamlewkowicz","description":"Treat Redux actions as they were events.","archived":false,"fork":false,"pushed_at":"2023-01-03T21:41:53.000Z","size":988,"stargazers_count":0,"open_issues_count":16,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-26T02:46:08.696Z","etag":null,"topics":["middleware","react","real-time","redux","reduxio","socket-io","websockets"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@art4/reduxio","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/adamlewkowicz.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}},"created_at":"2019-05-06T17:40:58.000Z","updated_at":"2021-02-13T10:02:21.000Z","dependencies_parsed_at":"2023-02-01T10:15:34.679Z","dependency_job_id":null,"html_url":"https://github.com/adamlewkowicz/reduxio","commit_stats":null,"previous_names":["alk831/redux-io"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/adamlewkowicz/reduxio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlewkowicz%2Freduxio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlewkowicz%2Freduxio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlewkowicz%2Freduxio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlewkowicz%2Freduxio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamlewkowicz","download_url":"https://codeload.github.com/adamlewkowicz/reduxio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlewkowicz%2Freduxio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31911447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["middleware","react","real-time","redux","reduxio","socket-io","websockets"],"created_at":"2025-03-18T06:17:46.720Z","updated_at":"2026-04-17T01:31:49.338Z","avatar_url":"https://github.com/adamlewkowicz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003ereduxio\u003c/h1\u003e\n  \u003cp\u003eTreat actions as they were events.\u003c/p\u003e\n  \u003cimg src=\"https://cdn.worldvectorlogo.com/logos/socket-io.svg\" align=\"center\" width=\"180\" height=\"180\"\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\u003chr /\u003e\n\n[![pipeline status](https://gitlab.com/alk831/redux-io/badges/master/pipeline.svg)](https://gitlab.com/alk831/redux-io/pipelines)\n[![Coverage Status](https://coveralls.io/repos/github/alk831/redux-io/badge.svg?branch=master)](https://coveralls.io/github/alk831/redux-io?branch=master)\n\u003c!-- [![Build Status](https://travis-ci.org/alk831/redux-io.svg?branch=master)](https://travis-ci.org/alk831/redux-io) --\u003e\nLightweight Redux middleware that simplifies creating real-time apps with socket.io.\n\n## Getting started\n```js\nnpm i @art4/reduxio\n```\n```js\nimport { createStore, applyMiddleware } from 'redux';\nimport io from 'socket.io-client';\nimport { createIoMiddleware } from '@art4/reduxio';\n\nconst socket = io('localhost');\n\nconst ioMiddleware = createIoMiddleware({\n  socket,\n  /* Listen to events (action types) that are going to be automatically dispatched to the store. */  \n  listenTo: ['MESSAGE_RECEIVE']\n});\n\nconst store = createStore(\n  reducers,\n  applyMiddleware(ioMiddleware)\n);\n```\n\n## How it works\n![Alt text](/diagram.png \"Reduxio diagram\")\n\n\n## Example\n### Client\n```js\nimport { createStore, applyMiddleware } from 'redux';\nimport io from 'socket.io-client';\nimport { createIoMiddleware } from '@art4/reduxio';\n\nconst socket = io('localhost');\n\nconst ioMiddleware = createIoMiddleware({\n  socket,\n  listenTo: ['$_MESSAGE_RECEIVE']\n});\n\nconst store = createStore(\n  reducers,\n  applyMiddleware(ioMiddleware)\n);\n\nstore.dispatch({\n  type: 'MESSAGE_SEND',\n  payload: 'Message sent from client'\n});\n```\n### Server\n\n```js\nsocket.on('MESSAGE_SEND', (action, dispatchOnce) =\u003e {\n\n  /* Emitting an action to connected clients, except the sender. */\n  socket.emit('$_MESSAGE_RECEIVE', {\n    type: '$_MESSAGE_RECEIVE',\n    payload: action.payload\n  });\n\n  /*\n    We are allowed to dispatch one action to the sender using the helper.\n    Obviously, dispatching more actions is available through emit.\n    Advantage of this approach is that we don't have to set up a listener for this action type.\n  */\n  dispatchOnce({ type: '$_MESSAGE_SUCCESS' });\n});\n```\n\n## API\n### createIoMiddleware (options: object)\nCreates redux middleware with options.\n\n**Options:**\n\n| Name   | Type   | Default | Required | Description |\n| ------ | ------ |:-------:|:--------:| ---- |\n| socket | Object | | yes | Socket.io client instance.\n| autoEmit | Boolean | `true` | | Automatically emit dispatched actions. Can be overwritten for specific action with meta `io: false` option.\n| listenTo | Array | `[]` | | Action types (event names) that are going to be automatically dispatched to the store.\n\n\u003cbr /\u003e\n\n### io: boolean | object\nOptions that are passed to action's meta as `io` property.\n\n**io: boolean**\nDetermines if the action has to be emitted or not.\n\n**io: object**\nAllows to pass options when emitting specific action.\n\n| Name   | Type   | Default | Description |\n| ------ | ------ |:-------:| ---- |\n| withState | Boolean | false | Emits action with current store state (after this action has been dispatched). |\n\n\u003cbr /\u003e\n\n## More examples\n\n### Emit with client's state\n*Client*\n```js\nstore.dispatch({\n  type: 'MESSAGE_SEND',\n  payload: 'Hello',\n  meta: { io: { withState: true }}\n});\n```\n*Server*\n```js\nsocket.on('MESSAGE_SEND', (action, state, dispatchOnce) =\u003e {\n  /*\n    Client's state is now available under the second argument.\n    Keep in mind that dispatchOnce is always provided as last argument.\n  */\n});\n```\n\n### Disable/enable emitting specific action\n```js\nconst ioMiddleware = createIoMiddleware({\n  socket,\n  autoEmit: true\n});\n\nconst store = createStore(\n  reducers,\n  applyMiddleware(ioMiddleware)\n);\n\nstore.dispatch({\n  type: 'MESSAGE_SEND',\n  payload: 'Hello',\n  meta: {\n    /* Auto emit option from middleware creator has lower priority, so this action won't be emitted. */\n    io: false\n  }\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamlewkowicz%2Freduxio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamlewkowicz%2Freduxio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamlewkowicz%2Freduxio/lists"}