{"id":13726043,"url":"https://github.com/sgdan/webview-redux","last_synced_at":"2025-05-07T21:31:02.977Z","repository":{"id":90656821,"uuid":"116224602","full_name":"sgdan/webview-redux","owner":"sgdan","description":"Provide a simple redux-like framework for the JavaFx WebView component","archived":false,"fork":false,"pushed_at":"2018-02-11T00:02:49.000Z","size":82,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-14T16:44:58.299Z","etag":null,"topics":["gui","javafx","kotlin","redux","webview"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/sgdan.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}},"created_at":"2018-01-04T06:42:09.000Z","updated_at":"2019-10-15T19:54:59.000Z","dependencies_parsed_at":"2023-07-09T02:46:09.957Z","dependency_job_id":null,"html_url":"https://github.com/sgdan/webview-redux","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgdan%2Fwebview-redux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgdan%2Fwebview-redux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgdan%2Fwebview-redux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgdan%2Fwebview-redux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgdan","download_url":"https://codeload.github.com/sgdan/webview-redux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252957121,"owners_count":21831438,"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":["gui","javafx","kotlin","redux","webview"],"created_at":"2024-08-03T01:02:50.359Z","updated_at":"2025-05-07T21:31:02.698Z","avatar_url":"https://github.com/sgdan.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# webview-redux [![Build Status](https://travis-ci.org/sgdan/webview-redux.svg?branch=master)](https://travis-ci.org/sgdan/webview-redux) [![Download](https://api.bintray.com/packages/sgdan/maven-releases/webview-redux/images/download.svg)](https://bintray.com/sgdan/maven-releases/webview-redux/_latestVersion)\nProvides a simple redux-like framework for the JavaFx WebView component.\n\nSee [CounterExample.kt](src/test/kotlin/com/github/sgdan/webviewredux/CounterExample.kt) which demonstrates\nbasic usage.\n\n### Get started\nAvailable from the jcenter repository.\n\nMaven:\n```Maven POM\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.sgdan\u003c/groupId\u003e\n  \u003cartifactId\u003ewebview-redux\u003c/artifactId\u003e\n  \u003cversion\u003e0.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\nGradle:\n```Gradle\ncompile 'com.github.sgdan:webview-redux:0.0.1'\n```\n\n### Redux class\nThe [Redux.kt](src/main/kotlin/com/github/sgdan/webviewredux/Redux.kt) class can be instantiated by providing:\n- a WebView component to use as display\n- the initial state: State\n- a view function: (State) -\u003e View\n- an update function: (State, Action) -\u003e State\n\n### View function\nThe view function can use the [kotlinx.html DSL](https://github.com/Kotlin/kotlinx.html) to\nbuild the view from the state:\n```Kotlin\nfun view(state: Int): Node = createDoc().create.html {\n        body {\n            h1 { +\"Counter\" }\n            +\"Current value: $state\"\n        }\n    }\n```\nAn Animation timer is used so that the view function won't be used more than once per screen\nrefresh cycle.\n\n### Events\nThe Redux class adds a `performAction` function to the JavaScript\ncontext of the WebView. This allows code in the view function to create named action events\nwith optional parameters:\n```Kotlin\nbutton {\n    +\"Clear\"\n    onClick = \"performAction('CLEAR');\"\n}\nbutton {\n    +\"Enter\"\n    onClick = \"performAction('ENTER', document.getElementById('input1').value, 'arg');\"\n}\n```\n\nEvents can also be triggered from a background thread or co-routine:\n```Kotlin\nlaunch {\n    while (true) {\n        delay(1000)\n        redux.perform(Action.TICK)\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgdan%2Fwebview-redux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgdan%2Fwebview-redux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgdan%2Fwebview-redux/lists"}