From 9d1be64e4d1d460c3a9ebd096c90955df8fbe638 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Mon, 14 Oct 2024 10:18:38 -0400 Subject: [PATCH] chore: publish stores (#3110) --- examples/stores/src/lib.rs | 1 - leptos_macro/Cargo.toml | 20 ++++++++++++++++---- reactive_stores/Cargo.toml | 7 ++++++- reactive_stores/README.md | 15 +++++++++++++++ reactive_stores/src/lib.rs | 2 +- reactive_stores/src/option.rs | 1 - reactive_stores_macro/Cargo.toml | 5 +++++ reactive_stores_macro/README.md | 1 + tachys/Cargo.toml | 4 +--- 9 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 reactive_stores/README.md create mode 100644 reactive_stores_macro/README.md diff --git a/examples/stores/src/lib.rs b/examples/stores/src/lib.rs index f83ea80a7..70ed1fd67 100644 --- a/examples/stores/src/lib.rs +++ b/examples/stores/src/lib.rs @@ -3,7 +3,6 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use chrono::{Local, NaiveDate}; use leptos::prelude::*; use reactive_stores::{Field, Patch, Store}; -use reactive_stores_macro::{Patch, Store}; use serde::{Deserialize, Serialize}; // ID starts higher than 0 because we have a few starting todos by default diff --git a/leptos_macro/Cargo.toml b/leptos_macro/Cargo.toml index e34b8a0b1..275541094 100644 --- a/leptos_macro/Cargo.toml +++ b/leptos_macro/Cargo.toml @@ -52,10 +52,22 @@ axum = ["server_fn_macro/axum"] [package.metadata.cargo-all-features] denylist = ["nightly", "tracing", "trace-component-props"] skip_feature_sets = [ - ["csr", "hydrate"], - ["hydrate", "csr"], - ["hydrate", "ssr"], - ["actix", "axum"] + [ + "csr", + "hydrate", + ], + [ + "hydrate", + "csr", + ], + [ + "hydrate", + "ssr", + ], + [ + "actix", + "axum", + ], ] [package.metadata.docs.rs] diff --git a/reactive_stores/Cargo.toml b/reactive_stores/Cargo.toml index 410d9dc52..b5cf4b418 100644 --- a/reactive_stores/Cargo.toml +++ b/reactive_stores/Cargo.toml @@ -1,6 +1,11 @@ [package] name = "reactive_stores" version = "0.1.0-gamma3" +authors = ["Greg Johnston"] +license = "MIT" +readme = "../README.md" +repository = "https://github.com/leptos-rs/leptos" +description = "Stores for holding deeply-nested reactive state while maintaining fine-grained reactive tracking." rust-version.workspace = true edition.workspace = true @@ -11,10 +16,10 @@ or_poisoned = { workspace = true } paste = "1.0" reactive_graph = { workspace = true } rustc-hash = "2.0" +reactive_stores_macro = { workspace = true } [dev-dependencies] tokio = { version = "1.39", features = ["rt-multi-thread", "macros"] } tokio-test = { version = "0.4.4" } any_spawner = { workspace = true, features = ["futures-executor", "tokio"] } -reactive_stores_macro = { workspace = true } reactive_graph = { workspace = true, features = ["effects"] } diff --git a/reactive_stores/README.md b/reactive_stores/README.md new file mode 100644 index 000000000..d8ca1271f --- /dev/null +++ b/reactive_stores/README.md @@ -0,0 +1,15 @@ +# Stores + +Stores are a data structure for nested reactivity. + +The [`reactive_graph`](https://crates.io/crates/reactive_graph) crate provides primitives for fine-grained reactivity +via signals, memos, and effects. + +This crate extends that reactivity to support reactive access to nested dested, without the need to create nested signals. + +Using the `#[derive(Store)]` macro on a struct creates a series of getters that allow accessing each field. Individual fields +can then be read as if they were signals. Changes to parents will notify their children, but changing one sibling field will +not notify any of the others, nor will it require diffing those sibling fields (unlike earlier solutions using memoized “slices”). + +This is published for use with the Leptos framework but can be used in any scenario where `reactive_graph` is being used +for reactivity. diff --git a/reactive_stores/src/lib.rs b/reactive_stores/src/lib.rs index 95cd160f6..a332f37e4 100644 --- a/reactive_stores/src/lib.rs +++ b/reactive_stores/src/lib.rs @@ -10,6 +10,7 @@ use reactive_graph::{ Write, }, }; +pub use reactive_stores_macro::*; use rustc_hash::FxHashMap; use std::{ any::Any, @@ -444,7 +445,6 @@ mod tests { effect::Effect, traits::{Read, ReadUntracked, Set, Update, Write}, }; - use reactive_stores_macro::{Patch, Store}; use std::sync::{ atomic::{AtomicUsize, Ordering}, Arc, diff --git a/reactive_stores/src/option.rs b/reactive_stores/src/option.rs index 101621ef8..048c1a6f7 100644 --- a/reactive_stores/src/option.rs +++ b/reactive_stores/src/option.rs @@ -51,7 +51,6 @@ mod tests { effect::Effect, traits::{Get, Read, ReadUntracked, Set, Write}, }; - use reactive_stores_macro::Store; use std::sync::{ atomic::{AtomicUsize, Ordering}, Arc, diff --git a/reactive_stores_macro/Cargo.toml b/reactive_stores_macro/Cargo.toml index 0afd835aa..f7030c372 100644 --- a/reactive_stores_macro/Cargo.toml +++ b/reactive_stores_macro/Cargo.toml @@ -1,6 +1,11 @@ [package] name = "reactive_stores_macro" version = "0.1.0-gamma3" +authors = ["Greg Johnston"] +license = "MIT" +readme = "../README.md" +repository = "https://github.com/leptos-rs/leptos" +description = "Stores for holding deeply-nested reactive state while maintaining fine-grained reactive tracking." rust-version.workspace = true edition.workspace = true diff --git a/reactive_stores_macro/README.md b/reactive_stores_macro/README.md new file mode 100644 index 000000000..937c51bf5 --- /dev/null +++ b/reactive_stores_macro/README.md @@ -0,0 +1 @@ +This crate provides macro that are helpful or required when using the `reactive_stores` crate. diff --git a/tachys/Cargo.toml b/tachys/Cargo.toml index 4bda484b0..e7eb53dc4 100644 --- a/tachys/Cargo.toml +++ b/tachys/Cargo.toml @@ -180,6 +180,4 @@ tracing = ["dep:tracing"] [package.metadata.cargo-all-features] denylist = ["tracing", "sledgehammer"] -skip_feature_sets = [ - ["ssr", "hydrate"], -] +skip_feature_sets = [["ssr", "hydrate"]]