Derive macro for State Management

Overview

sycamore-state is a utility library for better state management using sycamore's reactive primitives

the main features of this crate are the State derive macro and the Rc/Ref Collection signal types

currently for lifetime management this crate uses widely sycamore::reactive::create_signal_unsafe if you think there are possible unsafe errors feel free to open an issue

Current Features

Planned Features

Usage

```rust

[derive(Debug, State, Clone)]

[state(clone, eq, debug)] // avaliable derive macros are: (clone, debug, eq, ord)

pub struct MyState<'a> { pub field1: String, pub field2: u32, #[state] pub field3: MyInnerState<'a>, #[state] #[collection] pub statecollection: Vec> }

[derive(Debug, State, Clone)]

[state(clone, eq, debug)]

pub struct MyInnerState<'a> { pub field_1: i64, #[collection] pub collection: Vec<&'a str> }

let refstate = RefMyState::new(cx, MyState { field1: "mystring".into(), field2: 5, field3: MyInnerState { field1: 20, collection: vec!["my", "string", "collection"], }, state_collection: Default::default() });
```

Generated Structs

```rust pub struct RcMyState<'a> { pub field1: RcSignal, pub field2: RcSignal, pub field3: RcSignal>, pub statecollection: RcCollectionSignal>, }

pub struct RcMyInnerState<'a> { pub field_1: RcSignal, pub collection: RcCollectionSignal<&'a str>, }

pub struct RefMyState<'a, 'stateful> { pub field1: &'stateful Signal, pub field2: &'stateful Signal, pub field3: &'stateful Signal>, pub statecollection: RefCollectionSignal<'stateful, RefMyInnerState<'a, 'stateful>>, }

pub struct RefMyInnerState<'a, 'stateful> { pub field_1: &'stateful Signal, pub collection: RefCollectionSignal<'stateful, &'a str>, } ```