gstore
Global and local state management for GTK apps which implements the flux pattern. This crate targets apps written with gtk-rust-app framework.
A State can be any kind of data structure an application is based on. For a 'counter' app it might be a struct with a single u32 field. Actions are enums which represent the possible features of the app affecting the state.
Global store usage
// src/store.rs
pub const INCREMENT: &str = "increment";
// Given you have a global state
// Using the store macro a 'store' for this state
store!;
// The following public interface will be generated:
pub type Store = Store
/// Initialize the store and global state
///
/// # Arguments
/// - initializer: Initialize the state.
/// - reducer: Handle actions and mutate the state
/// - middlewares: Pre- and post-reduce handlers
// main.rs
// Initialize the store
// Implement a middleware
;
// Then in your GTK app you can dispatch actions to the store
let button: Button = builder.build;
button.connect_clicked;
Performance data
gstore can print basic performance information via the environment variabl GSTORE_PERF=1
;
License
gstore is distributed under the terms of the GPL-3.0 license. See LICENSE for details.