{"id":21257654,"url":"https://github.com/wallter/useecho","last_synced_at":"2025-08-26T03:21:29.040Z","repository":{"id":74276612,"uuid":"204698863","full_name":"wallter/useEcho","owner":"wallter","description":"useEcho is a React Hook for Laravel Echo + Socket.io for Event Broadcasting","archived":false,"fork":false,"pushed_at":"2023-09-19T22:38:03.000Z","size":5,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T06:27:20.953Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/wallter.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-27T12:31:39.000Z","updated_at":"2023-09-19T22:38:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"2110d812-ffaf-424c-8bcd-a6bf9f486239","html_url":"https://github.com/wallter/useEcho","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wallter/useEcho","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallter%2FuseEcho","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallter%2FuseEcho/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallter%2FuseEcho/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallter%2FuseEcho/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wallter","download_url":"https://codeload.github.com/wallter/useEcho/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallter%2FuseEcho/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272165253,"owners_count":24884673,"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","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-21T04:05:13.120Z","updated_at":"2025-08-26T03:21:29.024Z","avatar_url":"https://github.com/wallter.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# useEcho\n`useEcho` is a wrapper around [Laravel Echo](https://github.com/laravel/echo) ([docs](https://laravel.com/docs/5.8/broadcasting)) that exposes a react style hook to interact with channels to receive websocket events (via socket.io).\n\n# Usage\n\n#### 1. Generate Command:\n```sh\nphp artisan make:event OrdersUpdateEvent\n```\n\n#### 2. Setup `OrdersUpdateEvent::__construct()` and `brodcastOn()`. The key used in `brodcastOn()` is the channel, and the class name is the event key.\n\n```php\nclass OrdersUpdateEvent extends Event implements ShouldBroadcast\n{\n    use Dispatchable, InteractsWithSockets, SerializesModels;\n\n    public function __construct(public User $user, public BulkOrderUpdateRequest $request)\n    {\n    }\n\n    public function broadcastOn()\n    {\n        return ['app.order.updates'];\n    }\n}\n```\n\n#### 3. Javascript Hook usage within a context or component.\n```js\nuseEcho({\n  channel: 'app.order.updates', // key defined in OrdersUpdateEvent::brodcastOn()\n  events: {\n    // events are key/value pairs of: { [eventClassName]: fn_callback(payload) }\n    OrdersUpdateEvent: e =\u003e console.log('OrdersUpdateEvent', {\n      user,\n      request // the payload is passed as defined in OrdersUpdateEvent::__construct()\n    }),\n    OtherEvent: e =\u003e console.log('OtherEvent', e),\n  },\n});\n```\n\n# TODO\n* enable support for different types of channels (Private/Presence)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwallter%2Fuseecho","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwallter%2Fuseecho","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwallter%2Fuseecho/lists"}