{"id":21891113,"url":"https://github.com/maicolsantos/typeactionsredux","last_synced_at":"2026-03-11T01:31:16.799Z","repository":{"id":40755755,"uuid":"278157476","full_name":"maicolsantos/typeActionsRedux","owner":"maicolsantos","description":"We know that using Redux can be a bit verbose, with TypeActionsRedux you in addition to writing little, keep their types and actions organized.","archived":false,"fork":false,"pushed_at":"2023-01-06T11:29:58.000Z","size":998,"stargazers_count":3,"open_issues_count":12,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T20:37:10.770Z","etag":null,"topics":["actions","react","redux","type"],"latest_commit_sha":null,"homepage":"https://npm.im/type-actions-redux","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maicolsantos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-08T17:51:00.000Z","updated_at":"2022-09-09T13:10:00.000Z","dependencies_parsed_at":"2023-02-06T00:00:56.944Z","dependency_job_id":null,"html_url":"https://github.com/maicolsantos/typeActionsRedux","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/maicolsantos%2FtypeActionsRedux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maicolsantos%2FtypeActionsRedux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maicolsantos%2FtypeActionsRedux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maicolsantos%2FtypeActionsRedux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maicolsantos","download_url":"https://codeload.github.com/maicolsantos/typeActionsRedux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249081516,"owners_count":21209712,"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":["actions","react","redux","type"],"created_at":"2024-11-28T12:19:58.606Z","updated_at":"2026-03-11T01:31:16.744Z","avatar_url":"https://github.com/maicolsantos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeActionsRedux\n\n```\nyarn add type-actions-redux\n```\n\nWe know that using Redux can be a bit verbose, with TypeActionsRedux you\nin addition to writing little, keep their types and actions organized.\n\n### How we do it when we use redux\n\nFirst we create a file that contains the types.\n\n```js\n// types.js\n\nexport const INCREMENT = 'INCREMENT'\nexport const DECREMENT = 'DECREMENT'\n```\n\nThen we create another file that contains our actions.\n\n```js\n// actions.js\n\nimport * as types from './types'\n\nexport function increment() {\n  return {\n    type: types.INCREMENT,\n  }\n}\n\nexport function decrement() {\n  return {\n    type: types.DECREMENT,\n  }\n}\n```\n\n### Using TypeActionsRedux\n\nWith TypeActionsRedux you create an object that has the objective of creating a\ntype constant and one-time action function.\n\nThat way you abstract the verbosity of writing two files\n\n```js\nimport { typeActionsRedux } from 'type-actions-redux'\n\nconst { actions, types } = typeActionsRedux('scope', {\n  increment: () =\u003e ({}),\n  decrement: () =\u003e ({}),\n})\n```\n\n### Create actions with parameters\n\n```js\nimport { typeActionsRedux } from 'type-actions-redux'\n\nconst { actions, types } = typeActionsRedux('user', {\n  getUserData: (id) =\u003e ({ meta: { id } }),\n  setUserData: (data) =\u003e ({ payload: { data } }),\n})\n```\n\n### Output TypeActionsRedux\n\nWhat typeActionsRedux does is to export two objects, `types` and` actions`.\n\n```js\n// Output typeActionsRedux\n\nexport const types = {\n  GET_USER_DATA = 'user/GET_USER_DATA'\n  SET_USER_DATA = 'user/SET_USER_DATA'\n}\n\nexport const actions = {\n  getUserData(id) {\n    return {\n      type: types.GET_USER_DATA,\n      meta: { id },\n    }\n  },\n  setUserData(data) {\n    return {\n      type: types.SET_USER_DATA,\n      payload: { data },\n    }\n  },\n}\n\n```\n### Example using redux-saga\n\nRemember that the name of the function in typeActionsRedux will be the same name used in `types` and` actions`,\nbeing that in `types` he receives modifications to be uppercase and underline in cases of camelCase.\n\nSo when using a `type` in the saga for example, just use it like this\n\n```js\nimport { takeLatest } from 'redux-saga/effects'\n\nimport { types } from './actions'\n\nfunction* getUserDataSaga({ meta: { id }}) {\n  ...\n}\n\nexport default function* () {\n  yield takeLatest(\n    types.GET_USER_DATA,\n    getUserDataSaga,\n  )\n}\n```\n\n### How to use in the project\n\n```jsx\nimport React from 'react'\nimport { useDispatch } from 'react-redux'\n\nimport { actions } from './actions'\n\nconst App = () =\u003e {\n  const dispatch = useDispatch()\n\n  const handleClick = () =\u003e {\n    const id = 1\n\n    dispatch(actions.getUserData(id))\n  }\n\n  return (\n    \u003cbutton onClick={handleClick}\u003e\n      Press me\n    \u003c/button\u003e\n  )\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaicolsantos%2Ftypeactionsredux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaicolsantos%2Ftypeactionsredux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaicolsantos%2Ftypeactionsredux/lists"}