{"id":13561278,"url":"https://github.com/billstclair/elm-websocket-client","last_synced_at":"2025-07-12T02:12:08.517Z","repository":{"id":62418380,"uuid":"146382184","full_name":"billstclair/elm-websocket-client","owner":"billstclair","description":"Websockets for Elm 0.19, using ports","archived":false,"fork":false,"pushed_at":"2019-04-07T23:09:58.000Z","size":166,"stargazers_count":70,"open_issues_count":2,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-06T23:48:27.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://package.elm-lang.org/packages/billstclair/elm-websocket-client/latest","language":"Elm","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/billstclair.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-28T02:41:50.000Z","updated_at":"2024-05-31T12:34:49.000Z","dependencies_parsed_at":"2022-11-01T16:46:17.634Z","dependency_job_id":null,"html_url":"https://github.com/billstclair/elm-websocket-client","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-websocket-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-websocket-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-websocket-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-websocket-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/billstclair","download_url":"https://codeload.github.com/billstclair/elm-websocket-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248412082,"owners_count":21099046,"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-08-01T13:00:54.413Z","updated_at":"2025-04-11T13:53:45.609Z","avatar_url":"https://github.com/billstclair.png","language":"Elm","funding_links":[],"categories":["Elm"],"sub_categories":[],"readme":"# WebSockets for Elm 0.19\n\n[billstclair/elm-websocket-client](https://package.elm-lang.org/packages/billstclair/elm-websocket-client/latest) is a conversion of the Elm 0.18 WebSocket client to Elm 0.19, using ports instead of native code and an effects module.\n\nElm 0.19 shipped with no WebSocket client. It used to be in [elm-lang/websocket](https://package.elm-lang.org/packages/elm-lang/websocket/latest). I have heard that its interface is being redesigned, and it will reappear sometime in the future. This package provides an alternative to use until then.\n\nThe package as shipped will work with a pure Elm WebSocket simulator, which transforms messages you send with a function you provide and sends the result back immediately. See the [example](https://github.com/billstclair/elm-websocket-client/tree/master/example) README for instructions on setting up ports to make it use JavaScript code to do real WebSocket communication.\n\nThe example is live at [billstclair.github.io/elm-websocket-client](https://billstclair.github.io/elm-websocket-client/).\n\n## Keys and URLs\n\nThe old `WebSocket` package identified sockets by their URLs. You can do that with `WebSocketClient` if you want, by using the `open` function. But you can also assign a unique key to each connection, which enables multiple connections to a single URL, by using `openWithKey`. The `key` arg to the other action functions will be the URL if you used `open` or the `key` if you used `openWithKey`.\n\n## Using the Package\n\nThe Elm 0.18 `WebSocket` module, in the `elm-lang/websocket` package, was an `effect module`. This allowed it to update its state in the background, so your code didn't have to have anything to do with that. A regular `port module` isn't that lucky. The state for the `WebSocketClient` module needs to be stored in your application's `Model`, and you have to update it when you call its functions, or process a `Value` you receive from its subscription port.\n\nSee `Main.elm` and `PortFunnels.elm` in the the [example/src](https://github.com/billstclair/elm-websocket-client/tree/master/example/src) directory for details. `PortFunnels.elm` exposes a `State` type and an `initialState` constant.\n\nYou will usually copy `PortFunnels.elm` into your application's source directory, and, if you use other `PortFunnel` modules, modify it to support all of them. It is a `port module`, and it defines the two ports that are used by `example/site/index.html`, `cmdPort` and `subPort`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillstclair%2Felm-websocket-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbillstclair%2Felm-websocket-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillstclair%2Felm-websocket-client/lists"}