{"id":19451373,"url":"https://github.com/thekashey/react-push-channel","last_synced_at":"2025-07-08T20:33:13.956Z","repository":{"id":57342944,"uuid":"144852538","full_name":"theKashey/react-push-channel","owner":"theKashey","description":"🎈Context is to drill props down. React Push Channel to drill props up.","archived":false,"fork":false,"pushed_at":"2020-05-08T12:10:25.000Z","size":1413,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-24T23:05:50.110Z","etag":null,"topics":["context","events","props","react","react-helmet","react-side-effect"],"latest_commit_sha":null,"homepage":"","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/theKashey.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-08-15T12:51:25.000Z","updated_at":"2020-09-02T09:53:11.000Z","dependencies_parsed_at":"2022-09-16T07:51:20.210Z","dependency_job_id":null,"html_url":"https://github.com/theKashey/react-push-channel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/theKashey/react-push-channel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-push-channel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-push-channel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-push-channel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-push-channel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theKashey","download_url":"https://codeload.github.com/theKashey/react-push-channel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-push-channel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264343881,"owners_count":23593805,"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":["context","events","props","react","react-helmet","react-side-effect"],"created_at":"2024-11-10T16:41:27.188Z","updated_at":"2025-07-08T20:33:13.926Z","avatar_url":"https://github.com/theKashey.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-push-channel \n[![Greenkeeper badge](https://badges.greenkeeper.io/theKashey/react-push-channel.svg)](https://greenkeeper.io/)\n\n----\n\n[![NPM](https://nodei.co/npm/react-push-channel.png?downloads=true\u0026stars=true)](https://nodei.co/npm/react-push-channel/) \n\nContext is to drill props down. React Push Channel drill props up.\n\n# API\n#### `createChannel(initialValue, reducer?, initialValueForReducer?)`\ncreates a channel, with given initialValue(used for typing), and optional reducer.\nReducer will be applied to all stored `messages`, producing the result.\n\ncreateChannel return an object with 3 fields:\n - `Collector` - to collect all messages. \n    - `callback` - current value will be reported via callback.\n    - `[merge]` - enabled reducer on data. Ie merges everything into a single value. Otherwise would return last value.\n - `Push` - put message into the channel\n    - any props from initialValue\n - `Pop` - read the current active message. Pop __doesn't remove the message__(ie \"pops\"). Only `Push` component unmount removes it.\n\n## Use as React-helmet?\n\n```js\nimport {createChannel} from 'react-push-channel';\n\nconst helmet = createChannel({\n  title: '',\n  description: ''\n});\n\n// the root collector\n\u003chelmet.Collector \n  callback={helmet =\u003e this.setState({helmet})} // transfer reported info into the state \n  merge                                        // merge all data in reverse order \n\u003e\n   \u003chelmet.Push title=\"Page Title\"/\u003e\n   \u003chelmet.Push description=\"Page description\"/\u003e\n\u003c/helmet.Collector\u003e\n\n// or actually do the job\n\n\u003chelmet.Collector \n  callback={helmet =\u003e document.title=helmet.title} // actually SET THE TITLE! \n  merge                                         \n\u003e\n   \u003chelmet.Push title=\"Page Title\"/\u003e\n   \u003chelmet.Push description=\"Page description\"/\u003e\n\u003c/helmet.Collector\n```\n\n## React-Lock\n\nThis example uses reducer to basically calculate number or active locks, and `Pop`\nto read active value down the tree.\n```js\nconst Lock = createChannel({}, acc =\u003e acc + 1, 0);\n\n\u003cLock.Collector merge callback={locked =\u003e this.setState({locked: !!locked})}\u003e\n  \u003cLock.Push /\u003e\n  \u003cLock.Pop\u003e{locked =\u003e \u003cspan\u003e is {locked?'locked':'unlocked'}\u003c/Lock.Pop\u003e\n  // ^^ would be 1 and `locked`\n\u003c/Lock.Collector\u003e  \n```\n\n# Licence\n MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthekashey%2Freact-push-channel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthekashey%2Freact-push-channel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthekashey%2Freact-push-channel/lists"}