{"id":13998574,"url":"https://github.com/alloc/react-ch","last_synced_at":"2025-05-03T00:31:35.950Z","repository":{"id":107078567,"uuid":"225442725","full_name":"alloc/react-ch","owner":"alloc","description":"Event channels for React","archived":true,"fork":false,"pushed_at":"2023-10-19T23:27:15.000Z","size":385,"stargazers_count":27,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-25T22:37:46.213Z","etag":null,"topics":["events","reactjs"],"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/alloc.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-12-02T18:32:47.000Z","updated_at":"2024-11-11T16:57:11.000Z","dependencies_parsed_at":"2024-01-15T19:58:25.782Z","dependency_job_id":null,"html_url":"https://github.com/alloc/react-ch","commit_stats":{"total_commits":50,"total_committers":3,"mean_commits":"16.666666666666668","dds":"0.19999999999999996","last_synced_commit":"fa877101370c18b041f9cde2d21aea2491a6f4fd"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Freact-ch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Freact-ch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Freact-ch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Freact-ch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alloc","download_url":"https://codeload.github.com/alloc/react-ch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252126557,"owners_count":21698964,"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":["events","reactjs"],"created_at":"2024-08-09T19:01:47.354Z","updated_at":"2025-05-03T00:31:35.326Z","avatar_url":"https://github.com/alloc.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# react-ch\n\nThe `Channel` class is used to achieve loose coupling between an event source and its subscribers. To notify subscribers, it must be called as a function.\n\nThe `useChannel` hook has two different use cases.\n\n- as a shortcut for `useConstant(() =\u003e new Channel(name))`\n\n- for subscribing to a channel\n\n```ts\nconst didLogin = useChannel\u003cUser\u003e()\n\n// Listen for \"didLogin\" events while mounted.\nuseChannel(didLogin, (user: User) =\u003e {...})\n\n// Send an event to subscribers.\ndidLogin(user)\n```\n\n### Async decentralized work\n\nChannels can be used to depend on arbitrary work performed by subscribers. Every event has a promise that resolves with an array of return values (from subscribers).\n\n```ts\n// Use a channel to orchestrate animations.\nconst willAppear = useChannel\u003c[], void\u003e()\nawait willAppear()\n\n// In a deep descendant:\nuseChannel(willAppear, () =\u003e animate(...))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falloc%2Freact-ch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falloc%2Freact-ch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falloc%2Freact-ch/lists"}