{"id":16157890,"url":"https://github.com/mrxiaozhuox/golde","last_synced_at":"2025-03-18T20:30:55.106Z","repository":{"id":129903313,"uuid":"446031379","full_name":"mrxiaozhuox/golde","owner":"mrxiaozhuox","description":"Execute Javascript code in the Dioxus, and get the return value ( for Dioxus )","archived":false,"fork":false,"pushed_at":"2022-02-21T00:38:27.000Z","size":48,"stargazers_count":25,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T22:12:37.060Z","etag":null,"topics":["dioxus","javascript","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/mrxiaozhuox.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":"2022-01-09T08:18:28.000Z","updated_at":"2025-01-23T04:24:44.000Z","dependencies_parsed_at":"2023-07-23T14:30:10.547Z","dependency_job_id":null,"html_url":"https://github.com/mrxiaozhuox/golde","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrxiaozhuox%2Fgolde","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrxiaozhuox%2Fgolde/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrxiaozhuox%2Fgolde/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrxiaozhuox%2Fgolde/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrxiaozhuox","download_url":"https://codeload.github.com/mrxiaozhuox/golde/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243950792,"owners_count":20373664,"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":["dioxus","javascript","rust"],"created_at":"2024-10-10T01:51:07.095Z","updated_at":"2025-03-18T20:30:55.101Z","avatar_url":"https://github.com/mrxiaozhuox.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golde\n\n[Dioxus](https://github.com/DioxusLabs/dioxus)\n\n\u003e Execute Javascript code in the Dioxus, and get the return value.\n\nThis demo can help use `Javascript` to calc the `+` operator formula.\n\n```rust\nuse dioxus::prelude::*;\nuse fermi::*;\nuse golde::*;\n\nfn main() {\n    dioxus::desktop::launch(app)\n}\n\nstatic RESULT: Atom\u003cf64\u003e = |_| 0.0;\n\nfn app(cx: Scope) -\u003e Element {\n\n    init_app(\u0026cx, |initialized| {\n        // if you want to use `exec` or `call` in some conditional, you must pass the bool value for *_conditional;\n        // because in dioxus, any `hook-use` function cannot use in conditional.\n        exec_conditional(\u0026cx, \"console.log(1)\".into(), !initialized);\n    });\n\n    let a = use_state(\u0026cx, || 0.0);\n    let b = use_state(\u0026cx, || 0.0);\n\n    let res = use_read(\u0026cx, RESULT);\n    \n    let setter = use_set(\u0026cx, RESULT).clone();\n\n    cx.render(rsx!(\n        App {\n            trigger: trigger!(\n                test =\u003e move |_, v| {\n                    setter(v.as_number().unwrap_or(0.0));\n                }\n            ),\n            input {\n                value: \"{a}\",\n                onchange: move |data| a.set(\n                    data.value.parse::\u003cf64\u003e().unwrap_or(0.0)\n                )\n            }\n            input {\n                value: \"{b}\",\n                onchange: move |data| b.set(\n                    data.value.parse::\u003cf64\u003e().unwrap_or(0.0)\n                )\n            }\n            button {  \n                onclick: move |_| {\n                    let code = format!(\"{} + {}\", \u0026a, \u0026b);\n                    call(\u0026cx, \"test\", code.to_string());\n                },\n                \"Calc\"\n            }\n            p { \"Result: {res}\" }\n        }\n    ))\n}\n```\n\nThe `exec` function will not return the result, and `call` function can trigger the callback and get the result.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrxiaozhuox%2Fgolde","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrxiaozhuox%2Fgolde","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrxiaozhuox%2Fgolde/lists"}