{"id":20303887,"url":"https://github.com/billstclair/elm-port-funnel","last_synced_at":"2025-04-11T13:53:59.373Z","repository":{"id":57674866,"uuid":"147498177","full_name":"billstclair/elm-port-funnel","owner":"billstclair","description":"Funnel ALL your port modules through a single pair of ports","archived":false,"fork":false,"pushed_at":"2019-04-07T23:54:54.000Z","size":83,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T23:48:27.394Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://package.elm-lang.org/packages/billstclair/elm-port-funnel/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-09-05T10:05:35.000Z","updated_at":"2021-03-29T04:29:21.000Z","dependencies_parsed_at":"2022-09-02T15:01:40.186Z","dependency_job_id":null,"html_url":"https://github.com/billstclair/elm-port-funnel","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-port-funnel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-port-funnel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-port-funnel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-port-funnel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/billstclair","download_url":"https://codeload.github.com/billstclair/elm-port-funnel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248412091,"owners_count":21099048,"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-11-14T16:41:34.643Z","updated_at":"2025-04-11T13:53:59.351Z","avatar_url":"https://github.com/billstclair.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Funneling Your Ports\n\n[billstclair/elm-port-funnel](https://package.elm-lang.org/packages/billstclair/elm-port-funnel/latest) allows you to use a single outgoing/incoming pair of `port`s to communicate with the JavaScript for any number of `PortFunnel`-aware modules, which I'm going to call \"funnels\".\n\nOn the JavaScript side, you pick a directory for `PortFunnel.js` and the JavaScript files for the funnels. Some boilerplate JS in your `index.html` file loads `PortFunnel.js`, and tells it the names of the funnels. It takes care of loading them and wiring them up.\n\nOn the Elm side, you create the two ports, tell the `PortFunnel` module about them with a `ModuleDesc` instance, call the action functions in the funnel modules, in response to events, and dispatch off of the `name` field in the `GenericMessage` you get from your subscription port, to `process` that message in each specific module, and handle its `Result`. This is illustrated by three top-level applications in the [example directory](https://github.com/billstclair/elm-port-funnel/blob/master/example).\n\n[DEVELOPERS-GUIDE.md](https://github.com/billstclair/elm-port-funnel/blob/master/DEVELOPERS-GUIDE.md) has details for people who want to write funnels. For simple examples, see the files `Echo.elm` and `AddXY.elm` in the `src/PortFunnel` directory, and the corresponding `Echo.js` and `AddXY.js` files in the `example/site/js/PortFunnel` directory.\n\nThe README in the [example directory](https://github.com/billstclair/elm-port-funnel/tree/master/example) tells you how to configure the JavaScript for your own funnels. The main example is live at [billstclair.github.io/elm-port-funnel](https://billstclair.github.io/elm-port-funnel/).\n\n## Existing PortFunnel Modules\n\n`PortFunnel.Echo` and `PortFunnel.AddXY`, which ship with `billstclair/elm-port-funnel`, are the simple, canonical example modules. Below is a list of other funnel modules. If you write one, please add it to this list by submitting a pull request on this README file.\n\n* [billstclair/elm-dev-random](https://package.elm-lang.org/packages/billstclair/elm-dev-random/latest)\n\n  An interface to `window.crypto.getRandomValues()` for generating cryptographically secure random numbers.\n\n* [billstclair/elm-localstorage](https://package.elm-lang.org/packages/billstclair/elm-localstorage/latest)\n\n  An interface to the `localStorage` mechanism, for persistent storage.\n\n* [billstclair/elm-websocket-client](https://package.elm-lang.org/packages/billstclair/elm-websocket-client/latest)\n\n  A port-based replacement for the Elm 0.18 `elm-lang/websocket` package, which has not yet been upgraded to Elm 0.19.\n\n* [billstclair/elm-geolocation](https://package.elm-lang.org/packages/billstclair/elm-geolocation/latest)\n\n  A port-based replacement for the Elm 0.18 `elm-lang/geolocation` package, which was not upgraded when Elm 0.19 shipped, and may never be.\n\n## Credit\n\nThank you to Murphy Randall (@splodingsocks on Twitter and Elm Slack), whose [elm-conf 2017 talk](https://www.youtube.com/watch?v=P3pL85n9_5s) introduced me to the idea that `billstclair/elm-port-funnel` takes to its logical extreme.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillstclair%2Felm-port-funnel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbillstclair%2Felm-port-funnel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillstclair%2Felm-port-funnel/lists"}