{"id":25522284,"url":"https://github.com/launchscout/wc-state-reducers","last_synced_at":"2025-12-25T16:30:13.646Z","repository":{"id":33717075,"uuid":"147740159","full_name":"launchscout/wc-state-reducers","owner":"launchscout","description":"A state management library for web components that is so small you probably don't even need it","archived":false,"fork":false,"pushed_at":"2022-12-03T11:29:43.000Z","size":586,"stargazers_count":0,"open_issues_count":14,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-18T08:42:48.725Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/launchscout.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":"2018-09-06T22:22:43.000Z","updated_at":"2019-05-29T19:53:35.000Z","dependencies_parsed_at":"2023-01-15T02:11:32.841Z","dependency_job_id":null,"html_url":"https://github.com/launchscout/wc-state-reducers","commit_stats":null,"previous_names":["gaslight/wc-state-reducers"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Fwc-state-reducers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Fwc-state-reducers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Fwc-state-reducers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Fwc-state-reducers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/launchscout","download_url":"https://codeload.github.com/launchscout/wc-state-reducers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239708965,"owners_count":19684168,"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":"2025-02-19T18:19:13.875Z","updated_at":"2025-12-25T16:30:13.582Z","avatar_url":"https://github.com/launchscout.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wc-state-reducers\n\nwc-state-reducers is a very small library for managing state in an application built with \nweb components. It expects web components to:\n\n* get data passed to them via properties or attributes\n* render appropriately when new data is given to them\n* emit Custom Events when something happens that may change state\n\nwc-state-reducers exports a createStore function as follows:\n\n`createStore(element, reducers, subscribers, initialState?)`\n\nThe `element` is a DOMElement which \"owns\" the store in the sense that `stateChange` events are dispatched from this element. If you only need a single store for the page, it is fine to use `document`.\n\nThe `reducers` argument is an object whose keys are custom event names, and values are functions of the form `(currentState, eventDetail) =\u003e newState`. The eventDetail is the detail property of the CustomEvent. The `currentState` argument is the existing application state which may be destructured to pick off specific elements a given reducer is interested in. The return value is the new application state which is used as the payload in a `stateChange` Custom Event.\n\nThe store object returned has the following functions:\n\n* `subscribe`, which expects to receive a function which will get invoked with the current state as an argument on state changes.\n\nThis module also exports: \n\n`dispatch(element, name, eventDetail)`\n\nThis is a lil helper function which dispatches a bubbling custom event (this is important!) with the specified name and detail.\n\n## Example\n\nTo see it in action: \n* [Total Weight](https://github.com/gaslight/wc-state-reducers-example)\n* [Tic Tac Toe](https://github.com/gaslight/litelement-tic-tac-toe)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchscout%2Fwc-state-reducers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaunchscout%2Fwc-state-reducers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchscout%2Fwc-state-reducers/lists"}