{"id":13481452,"url":"https://github.com/arturkulig/react-whisper","last_synced_at":"2025-03-27T12:30:50.095Z","repository":{"id":57343915,"uuid":"126802582","full_name":"arturkulig/react-whisper","owner":"arturkulig","description":"Simple state management library for React","archived":true,"fork":false,"pushed_at":"2018-10-16T11:19:47.000Z","size":587,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T21:43:25.246Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://arturkulig.github.io/react-whisper/","language":"TypeScript","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/arturkulig.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-03-26T09:07:28.000Z","updated_at":"2024-03-21T09:22:19.000Z","dependencies_parsed_at":"2022-09-12T07:00:28.896Z","dependency_job_id":null,"html_url":"https://github.com/arturkulig/react-whisper","commit_stats":null,"previous_names":["arturkulig/react-rp-store"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturkulig%2Freact-whisper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturkulig%2Freact-whisper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturkulig%2Freact-whisper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturkulig%2Freact-whisper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arturkulig","download_url":"https://codeload.github.com/arturkulig/react-whisper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245844827,"owners_count":20681786,"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-07-31T17:00:51.939Z","updated_at":"2025-03-27T12:30:49.759Z","avatar_url":"https://github.com/arturkulig.png","language":"TypeScript","funding_links":[],"categories":["Components"],"sub_categories":["Data"],"readme":"# [React Whisper ️☝😮](https://arturkulig.github.io/react-whisper/)\n\nReact and TypeScript -enabled shared state distributors leveraging `render prop` pattern for ease of access to data.\n\n\u003e type annotations in examples are a TypeScript feature. TypeScript is optional, but recommended.\n\n## Install\n\n```bash\nnpm i react-whisper\n```\n\n## Store\n\nThis one is most basic. It is **just** a state distributor.\n\n### Create Store\n```tsx\nimport { createStore } from 'react-whisper'\nconst Store = createStore\u003cnumber\u003e(0)\n```\n\n### Read Store\n\n```tsx\nconst StoreAsString = () =\u003e \u003cStore\u003e{value =\u003e value.toString()}\u003c/Store\u003e\n```\n\n### Write to Store\n\n```tsx\nconst newValue = 5\nStore.next(newValue)\n```\n\n## Reducer\n\nThis quite close to what reducer in Redux is. You provide it with values that are not directly put to storage, but *reduced* and then broadcasted.\n\n### Create Reducer\n```tsx\nimport { createReducer } from 'react-whisper'\nconst Reducer = createReducer\u003cnumber, { op: 'add' | 'mult', value: number }\u003e(\n    0,\n    (state, { op, value }) =\u003e ({ add: state + value, mult: state * value}[op])\n)\n```\n\n### Read Reducer\n\n```tsx\nconst ReducerAsString = () =\u003e \u003cReducer\u003e{value =\u003e value.toString()}\u003c/Reducer\u003e\n```\n\n### Write to Reducer\n\n```tsx\nconst newValue = 5\nReducer.next({ op: 'add', value: newValue })\n```\n\n## Actor\n\nThis is an asynchronous reducer for most advanced usages. Get a message and release new state.\nThere is no requirement that amount of incoming and outgoing messages must match.\n\nTo make it easier to understand, example is as synchronous as possible.\n\n### Create Actor\n```tsx\nimport { createActor } from 'react-whisper'\nconst Actor = createActor\u003cnumber, { op: 'add' | 'mult', value: number }\u003e(\n    0,\n    async (mailbox, next) =\u003e {\n        let state = 0\n        for await (const { op, value } of mailbox) {\n            next(state = ({ add: state + value, mult: state * value }[op]))\n        }\n    }\n)\n```\n\n### Read Actor\n\n```tsx\nconst ActorAsString = () =\u003e \u003cActor\u003e{value =\u003e value.toString()}\u003c/Actor\u003e\n```\n\n### Write to Actor\n\n```tsx\nconst newValue = 5\nActor.next({ op: 'add', value: newValue })\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturkulig%2Freact-whisper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farturkulig%2Freact-whisper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturkulig%2Freact-whisper/lists"}