{"id":13566450,"url":"https://github.com/utkarshkukreti/draco","last_synced_at":"2025-04-07T12:07:13.138Z","repository":{"id":37910755,"uuid":"154799697","full_name":"utkarshkukreti/draco","owner":"utkarshkukreti","description":"Draco is a Rust library for building client side web applications with Web Assembly.","archived":false,"fork":false,"pushed_at":"2023-04-03T07:36:23.000Z","size":448,"stargazers_count":301,"open_issues_count":16,"forks_count":18,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-31T10:08:47.440Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/utkarshkukreti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2018-10-26T08:08:11.000Z","updated_at":"2025-02-26T14:10:16.000Z","dependencies_parsed_at":"2024-08-01T13:23:32.982Z","dependency_job_id":"fac34a27-77e8-4cb6-b2d2-d851cc4c9046","html_url":"https://github.com/utkarshkukreti/draco","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utkarshkukreti%2Fdraco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utkarshkukreti%2Fdraco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utkarshkukreti%2Fdraco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utkarshkukreti%2Fdraco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utkarshkukreti","download_url":"https://codeload.github.com/utkarshkukreti/draco/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648977,"owners_count":20972945,"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-08-01T13:02:09.871Z","updated_at":"2025-04-07T12:07:13.091Z","avatar_url":"https://github.com/utkarshkukreti.png","language":"Rust","funding_links":[],"categories":["Rust","Alternatives"],"sub_categories":["Frameworks"],"readme":"\n# Draco\n\n\u003e Draco is a Rust library to build client side web applications with Web\n\u003e Assembly.\n\n\u003e [Live Examples with Annotated Source](https://draco-examples.netlify.com/) |\n\u003e [Starter](https://github.com/utkarshkukreti/draco-starter)\n\n\u003e Note: This is the README for upcoming Draco 0.2.\n\u003e The README for the latest released version is\n\u003e [here](https://github.com/utkarshkukreti/draco/tree/0.1.2).\n\n## Overview\n\nThe \"Hello, World!\" of Draco ([with comments here](examples/hello_world/src/lib.rs)):\n\n```rust\nuse wasm_bindgen::prelude::*;\n\nstruct HelloWorld;\n\nimpl draco::Application for HelloWorld {\n    type Message = ();\n\n    fn view(\u0026self) -\u003e draco::VNode\u003cSelf::Message\u003e {\n        draco::html::h1().with(\"Hello, world!\").into()\n    }\n}\n\n#[wasm_bindgen(start)]\npub fn start() {\n    draco::start(HelloWorld, draco::select(\"main\").expect(\"\u003cmain\u003e\").into());\n}\n```\n\nDraco is modeled after The Elm Architecture and Redux. A Draco application\nimplements the `draco::Application` trait, which includes one type and two\nfunctions.\n\n```rust\npub trait Application {\n    type Message;\n\n    fn update(\u0026mut self, message: Self::Message, mailbox: \u0026Mailbox\u003cSelf::Message\u003e) {}\n    fn view(\u0026self) -\u003e Node\u003cSelf::Message\u003e;\n}\n```\n\nThe `view` function maps `\u0026self` to an HTML/SVG Node. The Node can emit\n`Message`s on certain events.\n\nThe `update` function takes `\u0026mut self`, a `Message` and a `draco::Mailbox`.\nThis function may update its fields based on the value of the Message. This\nfunction may also send more messages to itself or spawn a Future which will send\na message when it resolves, through the `Mailbox`.\n\n### Counter\n\nThis Counter example ([with comments here](examples/counter/src/lib.rs))\ndemonstrates an application which updates an integer value based on 3 types of\nmessages emitted from the view.\n\n```rust\nuse wasm_bindgen::prelude::*;\n\n#[derive(Default)]\npub struct Counter {\n    value: i32,\n}\n\npub enum Message {\n    Increment,\n    Decrement,\n    Reset,\n}\n\nimpl draco::Application for Counter {\n    type Message = Message;\n\n    fn update(\u0026mut self, message: Self::Message, _: \u0026draco::Mailbox\u003cSelf::Message\u003e) {\n        match message {\n            Message::Increment =\u003e self.value += 1,\n            Message::Decrement =\u003e self.value -= 1,\n            Message::Reset =\u003e self.value = 0,\n        }\n    }\n\n    fn view(\u0026self) -\u003e draco::VNode\u003cSelf::Message\u003e {\n        use draco::html as h;\n        h::div()\n            .with((\n                h::button().on(\"click\", |_| Message::Decrement).with(\"-\"),\n                \" \",\n                self.value,\n                \" \",\n                h::button().with(\"+\").on(\"click\", |_| Message::Increment),\n                \" \",\n                h::button().with(\"Reset\").on(\"click\", |_| Message::Reset),\n            ))\n            .into()\n    }\n}\n\n#[wasm_bindgen(start)]\npub fn start() {\n    draco::start(\n        Counter::default(),\n        draco::select(\"main\").expect(\"\u003cmain\u003e\").into(),\n    );\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futkarshkukreti%2Fdraco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futkarshkukreti%2Fdraco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futkarshkukreti%2Fdraco/lists"}