Crates.io | rs-store |
lib.rs | rs-store |
version | 0.12.0 |
source | src |
created_at | 2024-04-11 09:58:16.185475 |
updated_at | 2024-11-11 00:00:49.998 |
description | Redux Store for Rust |
homepage | |
repository | https://github.com/rookiecj/rs-store |
max_upload_size | |
id | 1204668 |
size | 58,776 |
rs-store is a Redux Store written in Rust.
Manage and receive notifications of state changes through the Reducer and Subscriber interfaces. Store registers Reducer and Subscriber, dispatches actions to change the state, and sends notifications to subscribers. Store is designed to change states in thread-safe manner.
rust documentation is available at crates.io and docs.rs.
pub fn main() {
println!("Hello, Calc!");
let store = Store::<CalcState, CalcAction>::new(Box::new(CalcReducer::default()));
store.add_subscriber(Arc::new(CalcSubscriber::default()));
store.dispatch(CalcAction::Add(1));
thread::sleep(std::time::Duration::from_secs(1));
store.add_subscriber(Arc::new(CalcSubscriber::default()));
store.dispatch(CalcAction::Subtract(1));
store.stop();
}