{"id":18206614,"url":"https://github.com/ecliptic/purescript-mini-redux","last_synced_at":"2025-04-02T15:30:40.334Z","repository":{"id":58242423,"uuid":"67938282","full_name":"ecliptic/purescript-mini-redux","owner":"ecliptic","description":"An idiomatic mini-interface to Redux for PureScript","archived":false,"fork":false,"pushed_at":"2017-04-11T21:13:02.000Z","size":74,"stargazers_count":11,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-22T08:44:26.821Z","etag":null,"topics":["javascript","purescript","redux"],"latest_commit_sha":null,"homepage":null,"language":"PureScript","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/ecliptic.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":"2016-09-11T15:39:55.000Z","updated_at":"2024-10-05T21:07:15.000Z","dependencies_parsed_at":"2022-08-31T00:41:05.679Z","dependency_job_id":null,"html_url":"https://github.com/ecliptic/purescript-mini-redux","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/ecliptic%2Fpurescript-mini-redux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecliptic%2Fpurescript-mini-redux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecliptic%2Fpurescript-mini-redux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecliptic%2Fpurescript-mini-redux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecliptic","download_url":"https://codeload.github.com/ecliptic/purescript-mini-redux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246744917,"owners_count":20826870,"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":["javascript","purescript","redux"],"created_at":"2024-11-03T12:05:32.164Z","updated_at":"2025-04-02T15:30:39.963Z","avatar_url":"https://github.com/ecliptic.png","language":"PureScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# purescript-mini-redux\n\n[![Latest release](https://img.shields.io/npm/v/purescript-mini-redux.svg)](https://github.com/ecliptic/purescript-mini-redux/releases)\n[![Latest release](https://img.shields.io/bower/v/purescript-mini-redux.svg)](https://github.com/ecliptic/purescript-mini-redux/releases)\n[![redux channel on discord](https://img.shields.io/badge/discord-%23redux%20%40%20reactiflux-61dafb.svg?style=flat-square)](https://discord.gg/2PCKqHc)\n[![Build Status](https://travis-ci.org/ecliptic/purescript-mini-redux.svg?branch=master)](https://travis-ci.org/ecliptic/purescript-mini-redux)\n\nAn idiomatic PureScript mini-interface to [Redux](http://redux.js.org/).\n\n## Why?\n\nBecause I want to work with Redux in an idiomatic way inspired by `purescript-redux-utils`, but in a more lightweight and less intrusive fashion. Store creation is still handled by your imperative code, but reducers and actions are defined in your PureScript modules, and thus they are strictly typed and purely functional.\n\nThis approach is inspired by the \"functional core, imperative shell\" strategy made popular by the Destroy All Software talk, [Boundaries](https://www.destroyallsoftware.com/talks/boundaries).\n\n## Usage\n\nInstall with bower:\n\n    $ bower install --save purescript-mini-redux\n\nDefine your root reducer and initial state with PureScript (only for this example - you can actually compose PureScript and plain JavaScript reducers any way you like):\n\n```purescript\nmodule MyApp.State.Store (rootReducer, initialState) where\n\nimport Control.Monad.Eff (Eff)\nimport MyApp.State.MyReducer (State, initialState, reducer) as MyReducer\nimport Redux.Mini (Store, STORE, ReduxReducer, combineReducers)\n\nrootReducer :: forall action state. ReduxReducer action state\nrootReducer = combineReducers { myReducer: MyReducer.reducer }\n\ninitialState :: { myReducer :: MyReducer.State }\ninitialState = { myReducer: MyReducer.initialState }\n```\n\nDefine your child reducers in PureScript as well:\n\n```purescript\nmodule MyApp.State.MyReducer\n  ( Action(..)\n  , State\n  , setMyValue\n  , initialState\n  , reducer\n  ) where\n\nimport Prelude\nimport Redux.Mini (Action) as Redux\nimport Redux.Mini (Reducer, ReduxReducer, createAction, createReducer)\n\ntype State = { myValue :: String }\n\n-- Actions ---------------------------------------------------------------------\n\ndata Action = Set String\n  | Else -- Represents external actions\n\nsetMyValue :: String -\u003e Redux.Action Action\nsetMyValue value = createAction $ Set value\n\n-- Reducer ---------------------------------------------------------------------\n\ninitialState :: State\ninitialState = { myValue: \"\" }\n\nmyReducer :: Reducer Action State\nmyReducer (Set value) state = state { myValue = value }\nmyReducer _ state = state\n\nreducer :: ReduxReducer Action State\nreducer = createReducer myReducer initialState\n```\n\nThen create your store with JavaScript:\n\n```javascript\n/* MyApp/State/Create.js */\nimport {rootReducer} from 'MyApp/State/Store.purs'\nimport * as Redux from 'redux'\n\nfunction devToolsEnhancer () {\n  if (typeof window === 'object' \u0026\u0026 typeof window.devToolsExtension !== 'undefined') {\n    return window.devToolsExtension()\n  }\n  return id =\u003e id\n}\n\nexport function createStore (initialState) {\n  const enhancers = [devToolsEnhancer()]\n\n  const store = Redux.createStore(\n    rootReducer,\n    initialState,\n    Redux.compose(...enhancers)\n  )\n\n  return store\n}\n```\n\nNow, you can call your createStore function and pass it an optional initialState value:\n\n```javascript\nimport {createStore} from 'MyApp/State/Create'\nimport {Provider} from 'react-redux'\n\nconst store = createStore()\n\nconst element = (\n  \u003cProvider store={store}\u003e\n    \u003cdiv\u003eMy awesome component is awesome!\u003c/div\u003e\n  \u003c/Provider\u003e\n)\n```\n\n## API Documentation\n\n* [Autogenerated API documentation](https://github.com/ecliptic/purescript-mini-redux/blob/master/docs/Redux/Mini.md)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecliptic%2Fpurescript-mini-redux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecliptic%2Fpurescript-mini-redux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecliptic%2Fpurescript-mini-redux/lists"}