{"id":19781956,"url":"https://github.com/jaredramirez/bs-elm","last_synced_at":"2025-04-30T22:30:31.731Z","repository":{"id":57348963,"uuid":"115359692","full_name":"jaredramirez/bs-elm","owner":"jaredramirez","description":"Bindings for mounting and interacting with Elm applications in Reason.","archived":false,"fork":false,"pushed_at":"2022-12-11T07:40:40.000Z","size":127,"stargazers_count":42,"open_issues_count":2,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-09-16T17:47:36.192Z","etag":null,"topics":["bs-elm","bucklescript","elm","reason-elm","reasonml"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/bs-elm","language":"Reason","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/jaredramirez.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}},"created_at":"2017-12-25T19:43:22.000Z","updated_at":"2020-12-07T19:42:21.000Z","dependencies_parsed_at":"2023-01-26T18:15:31.090Z","dependency_job_id":null,"html_url":"https://github.com/jaredramirez/bs-elm","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredramirez%2Fbs-elm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredramirez%2Fbs-elm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredramirez%2Fbs-elm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredramirez%2Fbs-elm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredramirez","download_url":"https://codeload.github.com/jaredramirez/bs-elm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224225339,"owners_count":17276435,"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":["bs-elm","bucklescript","elm","reason-elm","reasonml"],"created_at":"2024-11-12T06:03:13.794Z","updated_at":"2024-11-12T06:03:14.428Z","avatar_url":"https://github.com/jaredramirez.png","language":"Reason","funding_links":[],"categories":[],"sub_categories":[],"readme":"## bs-elm\n\n\u003e Bindings for mounting and interacting with Elm applications in Reason.\n\n### Motivation\n\nWriting web applications in Elm is nice. It's type system and enforced architecture\nare just a couple of the really cool things that it offers. The Elm ecosystem is\npretty small compared to the Javascript(JS) ecosystem, and this is a draw back\nwhen coming from the world of JS. Interop with JS is possible, but it requires\nwriting regular JS code, which has none of Elm's safety. This is where Reason\nenters the picture. Reason can communicate more direclty with JS with much more\ntype safety than vanilla JS. The possibility of writing an Elm app and handling\nJS interop with Reason is pretty powerful. Having access to the entire JS\necosytem in a (more) typesafe way is pretty exciting, so `bs-elm` was created.\n\n### Getting Started\n\n- Install\n  - With yarn: `yarn add bs-elm`\n  - With npm: `npm install --save bs-elm`\n- Add `bs-elm` as a dependency in `bsconfig.json`\n\n```\n{\n  ...\n  \"bs-dependencies\": [\"bs-elm\"]\n}\n```\n\n- Use the `Elm` module in reason\n\n```\nmodule R = Belt.Result;\n\ntype ports = {\n  infoForReason: Elm.elmToReasonPort(string),\n  infoForElm: Elm.reasonToElmPort(string),\n};\n\n[@bs.val] external elmProgram: Elm.elmProgramWithPorts(ports) = \"Elm\";\n/* Or if using a bundler.\n  [@bs.module]\n  external elmProgram : Elm.elmProgramWithPorts(ports) = \"path/to/App.elm\";\n*/\n\ntype flags = {...};\n\nlet resultRuntime =\n  Elm.mount(\n    ~flags={..}, /* Optional, defaults to Nothing */\n    ~moduleName=\"Other.Main\", /* Optional, defaults to \"Main\" */\n    elmProgram,\n  );\n\nswitch (resultRuntime) {\n| R.Ok(runtime) =\u003e\n  runtime.ports.infoForReason.subscribe(info =\u003e\n    runtime.ports.infoForElm.send(\"You pressed \" ++ info)\n  )\n| R.Error(message) =\u003e Js.log(message)\n};\n```\n\nCheckout the [`example/`](example)!\nCheckout this [repo using webpack](https://github.com/jaredramirez/bs-elm-example)!\n\n### Docs\n\nCheckout the [rei](src/Elm.rei) file for documenation.\n\nIf you have any suggestions or run into any bugs, please open an issue!\n\n### Change log\n\n`v3.0.0` -\u003e\n\n- Upgrade to bsb 7.3.2\n- Improve interop with new bsb records \u003c-\u003e js object compatability\n\n`v2.0.0` -\u003e\n\n- Drop support for 0.18\n- Add support for 0.19\n\n`v1.0.2` -\u003e\n\n- Compile reason modules in-source\n\n`v1.0.1` -\u003e\n\n- Upgrade to bs-platform@3.0.0 (No change in the generated code)\n- Generate files with the suffix `.bs.js` instead of `.js`\n- NOTE: If using webpack this, changes how the project must be built. Please refer to [jaredramirez/bs-elm-example](https://github.com/jaredramirez/bs-elm-example) for an example.\n\n`v1.0.0` -\u003e\n\n- Rename project to `bs-elm`\n- Changed exported module from `ReasonElm` to `Elm`\n- Changed export port types to `elmOutPort` -\u003e `portToElm` and `elmInPort` -\u003e `portFromElm`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredramirez%2Fbs-elm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredramirez%2Fbs-elm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredramirez%2Fbs-elm/lists"}