{"id":13566201,"url":"https://github.com/bounce-rs/bounce","last_synced_at":"2025-07-24T02:31:26.009Z","repository":{"id":37659414,"uuid":"431415107","full_name":"bounce-rs/bounce","owner":"bounce-rs","description":"The uncomplicated Yew State management library","archived":false,"fork":false,"pushed_at":"2024-01-22T19:20:50.000Z","size":329,"stargazers_count":101,"open_issues_count":16,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-20T14:43:04.184Z","etag":null,"topics":["rust","state-management","wasm","yew"],"latest_commit_sha":null,"homepage":"https://bounce-rs.org","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/bounce-rs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2021-11-24T09:07:29.000Z","updated_at":"2024-10-21T12:07:00.000Z","dependencies_parsed_at":"2024-04-10T04:38:08.275Z","dependency_job_id":"675c1876-8a2b-4661-9a68-c57840e75092","html_url":"https://github.com/bounce-rs/bounce","commit_stats":{"total_commits":159,"total_committers":5,"mean_commits":31.8,"dds":0.1572327044025157,"last_synced_commit":"ed3095a9e0728a14a3e409e862a564b05dbeb186"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/bounce-rs/bounce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bounce-rs%2Fbounce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bounce-rs%2Fbounce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bounce-rs%2Fbounce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bounce-rs%2Fbounce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bounce-rs","download_url":"https://codeload.github.com/bounce-rs/bounce/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bounce-rs%2Fbounce/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266785443,"owners_count":23983821,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["rust","state-management","wasm","yew"],"created_at":"2024-08-01T13:02:04.379Z","updated_at":"2025-07-24T02:31:25.990Z","avatar_url":"https://github.com/bounce-rs.png","language":"Rust","readme":"# Bounce\n\n[![Run Tests \u0026 Publishing](https://github.com/bounce-rs/bounce/actions/workflows/everything.yml/badge.svg)](https://github.com/bounce-rs/bounce/actions/workflows/everything.yml)\n[![crates.io](https://img.shields.io/crates/v/bounce)](https://crates.io/crates/bounce)\n[![docs.rs](https://docs.rs/bounce/badge.svg)](https://docs.rs/bounce/)\n\nThe uncomplicated state management library for Yew.\n\nBounce is inspired by [Redux](https://github.com/reduxjs/redux) and\n[Recoil](https://github.com/facebookexperimental/Recoil).\n\n## Rationale\n\nYew state management solutions that are currently available all have\nsome (or all) of the following limitations:\n\n- Too much boilerplate.\n\n   Users either have to manually control whether to notify\n   subscribers or have to manually define contexts.\n\n- State change notifies all.\n\n   State changes will notify all subscribers.\n\n- Needless clones.\n\n   A clone of the state will be produced for all subscribers whenever\nthere's a change.\n\nBounce wants to be a state management library that:\n\n- Has minimal boilerplate.\n\n   Changes are automatically detected via `PartialEq`.\n\n- Only notifies relevant subscribers.\n\n   When a state changes, only hooks that subscribe to that state will\nbe notified.\n\n- Reduces Cloning.\n\n   States are `Rc`'ed.\n\n## Example\n\nFor bounce states to function, a `\u003cBounceRoot /\u003e` must be registered.\n\n```rust\n#[function_component(App)]\nfn app() -\u003e Html {\n    html! {\n        \u003cBounceRoot\u003e\n            {children}\n        \u003c/BounceRoot\u003e\n    }\n}\n```\n\nA simple state is called an `Atom`.\n\nYou can derive `Atom` for any struct that implements `PartialEq` and `Default`.\n\n```rust\n#[derive(PartialEq, Atom)]\nstruct Username {\n    inner: String,\n}\n\nimpl Default for Username {\n    fn default() -\u003e Self {\n        Self {\n            inner: \"Jane Doe\".into(),\n        }\n    }\n}\n```\n\nYou can then use it with the `use_atom` hook.\n\nWhen an `Atom` is first used, it will be initialised with its `Default`\nvalue.\n\n```rust\n#[function_component(Setter)]\nfn setter() -\u003e Html {\n    let username = use_atom::\u003cUsername\u003e();\n\n    let on_text_input = {\n        let username = username.clone();\n\n        Callback::from(move |e: InputEvent| {\n            let input: HtmlInputElement = e.target_unchecked_into();\n\n            username.set(Username { inner: input.value().into() });\n        })\n    };\n\n    html! {\n        \u003cdiv\u003e\n            \u003cinput type=\"text\" oninput={on_text_input} value={username.inner.to_string()} /\u003e\n        \u003c/div\u003e\n    }\n}\n```\n\nIf you wish to create a read-only (or set-only) handle, you can use\n`use_atom_value` (or `use_atom_setter`).\n\n```rust\n#[function_component(Reader)]\nfn reader() -\u003e Html {\n    let username = use_atom_value::\u003cUsername\u003e();\n\n    html! { \u003cdiv\u003e{\"Hello, \"}{\u0026username.inner}\u003c/div\u003e }\n}\n```\n\nYou can find the full example [here](https://github.com/futursolo/bounce/blob/master/examples/simple/src/main.rs).\n\n## License\n\nBounce is dual licensed under the MIT license and the Apache License (Version 2.0).\n","funding_links":[],"categories":["Crates","Rust"],"sub_categories":["Hooks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbounce-rs%2Fbounce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbounce-rs%2Fbounce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbounce-rs%2Fbounce/lists"}