{"id":16506218,"url":"https://github.com/keller-mark/anyhtmlwidget","last_synced_at":"2025-03-21T08:31:12.764Z","repository":{"id":240258846,"uuid":"801754028","full_name":"keller-mark/anyhtmlwidget","owner":"keller-mark","description":"Bringing core concepts from anywidget to R","archived":false,"fork":false,"pushed_at":"2024-12-05T19:43:45.000Z","size":95,"stargazers_count":15,"open_issues_count":9,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T22:54:52.907Z","etag":null,"topics":["hidivelab"],"latest_commit_sha":null,"homepage":"https://keller-mark.github.io/anyhtmlwidget/","language":"R","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/keller-mark.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":"2024-05-16T21:06:56.000Z","updated_at":"2025-01-21T18:44:40.000Z","dependencies_parsed_at":"2024-06-14T22:29:54.285Z","dependency_job_id":"5a5938f2-8332-44f4-b5ae-2375fd52e416","html_url":"https://github.com/keller-mark/anyhtmlwidget","commit_stats":null,"previous_names":["keller-mark/anyhtmlwidget"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keller-mark%2Fanyhtmlwidget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keller-mark%2Fanyhtmlwidget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keller-mark%2Fanyhtmlwidget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keller-mark%2Fanyhtmlwidget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keller-mark","download_url":"https://codeload.github.com/keller-mark/anyhtmlwidget/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244764927,"owners_count":20506732,"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":["hidivelab"],"created_at":"2024-10-11T15:17:58.442Z","updated_at":"2025-03-21T08:31:12.372Z","avatar_url":"https://github.com/keller-mark.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# anyhtmlwidget\n\nBringing core concepts from [anywidget](https://github.com/manzt/anywidget) to R.\n\n- Define widget as a JavaScript EcmaScript Module (ESM) string in R\n- Access state from JS using the same AnyWidget `model` API.\n- Bidirectional communication (R \u003c-\u003e JS)\n\n## Installation\n\n```R\ndevtools::install_github(\"keller-mark/anyhtmlwidget\")\n```\n\n## Usage\n\n```R\nlibrary(anyhtmlwidget)\n\nesm \u003c- \"\nfunction render({ el, model }) {\n  let count = () =\u003e model.get('count');\n  let btn = document.createElement('button');\n  btn.innerHTML = `count button ${count()}`;\n  btn.addEventListener('click', () =\u003e {\n    model.set('count', count() + 1);\n    model.save_changes();\n  });\n  model.on('change:count', () =\u003e {\n        btn.innerHTML = `count is ${count()}`;\n  });\n  el.appendChild(btn);\n}\nexport default { render };\n\"\n\nwidget \u003c- AnyHtmlWidget$new(.esm = esm, .mode = \"dynamic\", count = 1)\nwidget$render()\n```\n\nSetting a value will cause a re-render:\n\n```R\nwidget$count \u003c- 2\n```\n\nAccess the latest values:\n\n```R\nwidget$count\n# [1] 2\n```\n\n## Modes\n\n- `dynamic`: Bidirectional communication via background WebSocket server. Does not block R console.\n- `gadget`: Bidirectional communication via Shiny running as a Gadget. Blocks R console.\n- `static`: Unidirectional communication (R -\u003e JS). Does not block R console.\n- `shiny`: Bidirectional communication. Use when embedding a widget in a Shiny app.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeller-mark%2Fanyhtmlwidget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeller-mark%2Fanyhtmlwidget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeller-mark%2Fanyhtmlwidget/lists"}