{"id":15285986,"url":"https://github.com/bendyworks/elm-action-cable","last_synced_at":"2025-07-19T04:32:30.387Z","repository":{"id":57674853,"uuid":"86864675","full_name":"bendyworks/elm-action-cable","owner":"bendyworks","description":"Client-side Elm library for ActionCable, part of the Ruby on Rails suite","archived":false,"fork":false,"pushed_at":"2017-04-06T21:36:00.000Z","size":69,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-07T03:46:10.012Z","etag":null,"topics":["actioncable","elm","elm-lang","rails"],"latest_commit_sha":null,"homepage":"http://package.elm-lang.org/packages/bendyworks/elm-action-cable/latest","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bendyworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-31T22:21:42.000Z","updated_at":"2017-10-13T16:11:31.000Z","dependencies_parsed_at":"2022-09-02T17:08:58.211Z","dependency_job_id":null,"html_url":"https://github.com/bendyworks/elm-action-cable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bendyworks/elm-action-cable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendyworks%2Felm-action-cable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendyworks%2Felm-action-cable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendyworks%2Felm-action-cable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendyworks%2Felm-action-cable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bendyworks","download_url":"https://codeload.github.com/bendyworks/elm-action-cable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendyworks%2Felm-action-cable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265888898,"owners_count":23844527,"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":["actioncable","elm","elm-lang","rails"],"created_at":"2024-09-30T15:08:59.055Z","updated_at":"2025-07-19T04:32:30.369Z","avatar_url":"https://github.com/bendyworks.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActionCable in Elm\n\nThis package is an Elm client library for [ActionCable][ActionCable guide], which comes bundled with Ruby on Rails.\n\n## Basic Usage\n\n```elm\nimport ActionCable\nimport ActionCable.Msg as ACMsg\nimport ActionCable.Identifier as ID\n\n\ninitModel : (Model, Cmd Msg)\ninitModel =\n    { cable =\n        ActionCable.initCable \"ws://localhost:3000/cable/\"\n            |\u003e ActionCable.onDidReceiveData (Just HandleData)\n            |\u003e ActionCable.withDebug True\n    , errorToast = Nothing\n    , ...\n    } ! []\n\n\ntype Msg\n    = CableMsg ACMsg.Msg\n    | SubscribeTo String\n    | UnsubscribeFrom String\n    | HandleData ID.Identifier Json.Decode.Value\n    | SendData String String\n\n\nupdate : Msg -\u003e Model -\u003e ( Model, Cmd Msg )\nupdate msg model =\n    case msg of\n        SubscribeTo roomName -\u003e\n          subscribeTo roomName model\n\n        UnsubscribeFrom roomName -\u003e\n          unsubscribeFrom roomName model\n\n        HandleData identifier value -\u003e\n            -- value is a Json.Decode.Value. You'll probably want to use\n            -- Json.Decode.decodeValue\n            { model | messages = toString value :: model.messages } ! []\n\n        SendData roomName aStringToSend -\u003e\n          sendData roomName aStringToSend model\n\n        CableMsg cableMsg -\u003e\n            -- important to forward on \"accounting\" messages to the underlying submodel\n            ActionCable.update cableMsg model.cable\n                |\u003e (\\( cable, cmd ) -\u003e { model | cable = cable } ! [ cmd ])\n\n\nsubscribeTo : String -\u003e Model -\u003e (Model, Cmd Msg)\nsubscribeTo roomName model =\n    case ActionCable.subscribeTo (channelId roomName) model.cable of\n        Ok ( cable, cmd ) -\u003e\n            { model | cable = cable } ! [ Cmd.map CableMsg cmd ]\n\n        Err err -\u003e\n            -- you're probably already subscribed to this channel\n            { model | errorToast = Just \u003c| ActionCable.errorToString err } ! []\n\n\nunsubscribeFrom : String -\u003e Model -\u003e (Model, Cmd Msg)\nunsubscribeFrom roomName model =\n    case ActionCable.unsubscribeFrom (channelId roomName) model.cable of\n        Ok ( cable, cmd ) -\u003e\n            { model | cable = cable } ! [ Cmd.map CableMsg cmd ]\n\n        Err err -\u003e\n            -- you're probably already unsubscribed from this channel\n            { model | errorToast = Just \u003c| ActionCable.errorToString err } ! []\n\n\nsendData : String -\u003e String -\u003e Model -\u003e (Model, Cmd Msg)\nsendData roomName aStringToSend model =\n    let\n        sendCmd =\n            ActionCable.perform\n                \"some_channel_action_name\"\n                [ ( \"jsonKey\", Json.Encode.string aStringToSend ) ]\n                (channelId roomName)\n                model.cable\n    in\n        case sendCmd of\n            Ok toSend -\u003e\n                model ! [ toSend ]\n\n            Err err -\u003e\n                -- probably because you haven't subscribed to the channel yet\n                { model | errorToast = Just \u003c| ActionCable.errorToString err } ! []\n\n\nchannelId : String -\u003e ID.Identifier\nchannelId roomName =\n    ID.newIdentifier \"ChatChannel\" [ ( \"room\", roomName ) ]\n\n\n-- subscriptions\n\n\nsubscriptions : Model -\u003e Sub Msg\nsubscriptions model =\n    ActionCable.listen CableMsg model.cable\n```\n\n\n## License\n\n`elm-action-cable` is released under the Apache v2 license, the details of which can be found in the LICENSE file.\n\n## Author\n\n* [Brad Grzesiak](https://twitter.com/listrophy), [Bendyworks](http://bendyworks.com)\n\n\n[ActionCable guide]: http://guides.rubyonrails.org/action_cable_overview.html \"ActionCable guide\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendyworks%2Felm-action-cable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbendyworks%2Felm-action-cable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendyworks%2Felm-action-cable/lists"}