Skip to content

Commit

Permalink
put the store fields implementation under the "reactive_stores" featu…
Browse files Browse the repository at this point in the history
…re flag
  • Loading branch information
mahdi739 committed Feb 11, 2025
1 parent 0b2a835 commit 5604fa7
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 26 deletions.
33 changes: 29 additions & 4 deletions tachys/src/reactive_graph/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ mod stable {
};
}

#[cfg(feature = "reactive_stores")]
macro_rules! class_store_field {
($name:ident, <$($gen:ident),*>, $v:ty, $( $where_clause:tt )*) =>
{
Expand Down Expand Up @@ -1220,6 +1221,7 @@ mod stable {
};
}

#[cfg(feature = "reactive_stores")]
macro_rules! tuple_class_store_field {
($name:ident, <$($impl_gen:ident),*>, <$($gen:ident),*> , $v:ty, $( $where_clause:tt )*) => {
impl<$($impl_gen),*> IntoClass for (&'static str, $name<$($gen),*>)
Expand Down Expand Up @@ -1397,12 +1399,16 @@ mod stable {
traits::Get,
wrappers::read::{ArcSignal, Signal},
};
use reactive_stores::{
ArcField, ArcStore, AtIndex, AtKeyed, DerefedField, Field,
KeyedSubfield, Store, StoreField, Subfield,
#[cfg(feature = "reactive_stores")]
use {
reactive_stores::{
ArcField, ArcStore, AtIndex, AtKeyed, DerefedField, Field,
KeyedSubfield, Store, StoreField, Subfield,
},
std::ops::{Deref, DerefMut, Index, IndexMut},
};
use std::ops::{Deref, DerefMut, Index, IndexMut};

#[cfg(feature = "reactive_stores")]
class_store_field!(
Subfield,
<Inner, Prev, V>,
Expand All @@ -1411,6 +1417,8 @@ mod stable {
Prev: Send + Sync + 'static,
Inner: Send + Sync + Clone + 'static,
);

#[cfg(feature = "reactive_stores")]
class_store_field!(
AtKeyed,
<Inner, Prev, K, V>,
Expand All @@ -1421,6 +1429,8 @@ mod stable {
K: Send + Sync + std::fmt::Debug + Clone + 'static,
for<'a> &'a V: IntoIterator,
);

#[cfg(feature = "reactive_stores")]
class_store_field!(
KeyedSubfield,
<Inner, Prev, K, V>,
Expand All @@ -1431,6 +1441,8 @@ mod stable {
K: Send + Sync + std::fmt::Debug + Clone + 'static,
for<'a> &'a V: IntoIterator,
);

#[cfg(feature = "reactive_stores")]
class_store_field!(
DerefedField,
<S>,
Expand All @@ -1439,6 +1451,7 @@ mod stable {
<S as StoreField>::Value: Deref + DerefMut
);

#[cfg(feature = "reactive_stores")]
class_store_field!(
AtIndex,
<Inner, Prev>,
Expand All @@ -1448,6 +1461,7 @@ mod stable {
Inner: Send + Sync + Clone + 'static,
);

#[cfg(feature = "reactive_stores")]
tuple_class_store_field!(
Subfield,
<Inner, Prev>,
Expand All @@ -1457,6 +1471,8 @@ mod stable {
Prev: Send + Sync + 'static,
Inner: Send + Sync + Clone + 'static,
);

#[cfg(feature = "reactive_stores")]
tuple_class_store_field!(
AtKeyed,
<Inner, Prev, K>,
Expand All @@ -1468,6 +1484,8 @@ mod stable {
K: Send + Sync + std::fmt::Debug + Clone + 'static,
for<'a> &'a bool: IntoIterator,
);

#[cfg(feature = "reactive_stores")]
tuple_class_store_field!(
KeyedSubfield,
<Inner, Prev, K>,
Expand All @@ -1479,6 +1497,8 @@ mod stable {
K: Send + Sync + std::fmt::Debug + Clone + 'static,
for<'a> &'a bool: IntoIterator,
);

#[cfg(feature = "reactive_stores")]
tuple_class_store_field!(
DerefedField,
<S>,
Expand All @@ -1488,6 +1508,7 @@ mod stable {
<S as StoreField>::Value: Deref<Target = bool> + DerefMut
);

#[cfg(feature = "reactive_stores")]
tuple_class_store_field!(
AtIndex,
<Inner, Prev>,
Expand All @@ -1498,14 +1519,18 @@ mod stable {
Inner: Send + Sync + Clone + 'static,
);

#[cfg(feature = "reactive_stores")]
class_signal_arena!(Store);
#[cfg(feature = "reactive_stores")]
class_signal_arena!(Field);
class_signal_arena!(RwSignal);
class_signal_arena!(ReadSignal);
class_signal_arena!(Memo);
class_signal_arena!(Signal);
class_signal_arena!(MaybeSignal);
#[cfg(feature = "reactive_stores")]
class_signal!(ArcStore);
#[cfg(feature = "reactive_stores")]
class_signal!(ArcField);
class_signal!(ArcRwSignal);
class_signal!(ArcReadSignal);
Expand Down
25 changes: 21 additions & 4 deletions tachys/src/reactive_graph/inner_html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ mod stable {
traits::Get,
wrappers::read::{ArcSignal, Signal},
};
use reactive_stores::{
ArcField, ArcStore, AtIndex, AtKeyed, DerefedField, Field,
KeyedSubfield, Store, StoreField, Subfield,
#[cfg(feature = "reactive_stores")]
use {
reactive_stores::{
ArcField, ArcStore, AtIndex, AtKeyed, DerefedField, Field,
KeyedSubfield, Store, StoreField, Subfield,
},
std::ops::{Deref, DerefMut, Index, IndexMut},
};
use std::ops::{Deref, DerefMut, Index, IndexMut};

macro_rules! inner_html_signal {
($sig:ident) => {
Expand Down Expand Up @@ -336,6 +339,7 @@ mod stable {
};
}

#[cfg(feature = "reactive_stores")]
macro_rules! inner_html_store_field {
($name:ident, <$($gen:ident),*>, $v:ty, $( $where_clause:tt )*) =>
{
Expand Down Expand Up @@ -451,6 +455,7 @@ mod stable {
};
}

#[cfg(feature = "reactive_stores")]
inner_html_store_field!(
Subfield,
<Inner, Prev, V>,
Expand All @@ -459,6 +464,8 @@ mod stable {
Prev: Send + Sync + 'static,
Inner: Send + Sync + Clone + 'static,
);

#[cfg(feature = "reactive_stores")]
inner_html_store_field!(
AtKeyed,
<Inner, Prev, K, V>,
Expand All @@ -469,6 +476,8 @@ mod stable {
K: Send + Sync + std::fmt::Debug + Clone + 'static,
for<'a> &'a V: IntoIterator,
);

#[cfg(feature = "reactive_stores")]
inner_html_store_field!(
KeyedSubfield,
<Inner, Prev, K, V>,
Expand All @@ -479,13 +488,17 @@ mod stable {
K: Send + Sync + std::fmt::Debug + Clone + 'static,
for<'a> &'a V: IntoIterator,
);

#[cfg(feature = "reactive_stores")]
inner_html_store_field!(
DerefedField,
<S>,
<S::Value as Deref>::Target,
S: Clone + StoreField + Send + Sync + 'static,
<S as StoreField>::Value: Deref + DerefMut
);

#[cfg(feature = "reactive_stores")]
inner_html_store_field!(
AtIndex,
<Inner, Prev>,
Expand All @@ -495,14 +508,18 @@ mod stable {
Inner: Send + Sync + Clone + 'static,
);

#[cfg(feature = "reactive_stores")]
inner_html_signal_arena!(Store);
#[cfg(feature = "reactive_stores")]
inner_html_signal_arena!(Field);
inner_html_signal_arena!(RwSignal);
inner_html_signal_arena!(ReadSignal);
inner_html_signal_arena!(Memo);
inner_html_signal_arena!(Signal);
inner_html_signal_arena!(MaybeSignal);
#[cfg(feature = "reactive_stores")]
inner_html_signal!(ArcStore);
#[cfg(feature = "reactive_stores")]
inner_html_signal!(ArcField);
inner_html_signal!(ArcRwSignal);
inner_html_signal!(ArcReadSignal);
Expand Down
29 changes: 22 additions & 7 deletions tachys/src/reactive_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,14 @@ mod stable {
traits::Get,
wrappers::read::{ArcSignal, Signal},
};
use reactive_stores::{
ArcField, ArcStore, AtIndex, AtKeyed, DerefedField, Field,
KeyedSubfield, Store, StoreField, Subfield,
};
use std::{
ops::{Deref, DerefMut, Index, IndexMut},
sync::Arc,
use std::sync::Arc;
#[cfg(feature = "reactive_stores")]
use {
reactive_stores::{
ArcField, ArcStore, AtIndex, AtKeyed, DerefedField, Field,
KeyedSubfield, Store, StoreField, Subfield,
},
std::ops::{Deref, DerefMut, Index, IndexMut},
};

macro_rules! signal_impl {
Expand Down Expand Up @@ -1113,6 +1114,7 @@ mod stable {
};
}

#[cfg(feature = "reactive_stores")]
macro_rules! store_field_impl {
($name:ident, <$($gen:ident),*>, $v:ty, $dry_resolve:literal, $( $where_clause:tt )*) =>
{
Expand Down Expand Up @@ -1399,6 +1401,7 @@ mod stable {
};
}

#[cfg(feature = "reactive_stores")]
store_field_impl!(
Subfield,
<Inner, Prev, V>,
Expand All @@ -1408,6 +1411,8 @@ mod stable {
Prev: Send + Sync + 'static,
Inner: Send + Sync + Clone + 'static,
);

#[cfg(feature = "reactive_stores")]
store_field_impl!(
AtKeyed,
<Inner, Prev, K, V>,
Expand All @@ -1419,6 +1424,8 @@ mod stable {
K: Send + Sync + std::fmt::Debug + Clone + 'static,
for<'a> &'a V: IntoIterator,
);

#[cfg(feature = "reactive_stores")]
store_field_impl!(
KeyedSubfield,
<Inner, Prev, K, V>,
Expand All @@ -1430,6 +1437,8 @@ mod stable {
K: Send + Sync + std::fmt::Debug + Clone + 'static,
for<'a> &'a V: IntoIterator,
);

#[cfg(feature = "reactive_stores")]
store_field_impl!(
DerefedField,
<S>,
Expand All @@ -1438,6 +1447,8 @@ mod stable {
S: Clone + StoreField + Send + Sync + 'static,
<S as StoreField>::Value: Deref + DerefMut
);

#[cfg(feature = "reactive_stores")]
store_field_impl!(
AtIndex,
<Inner, Prev>,
Expand All @@ -1448,14 +1459,18 @@ mod stable {
Inner: Send + Sync + Clone + 'static,
);

#[cfg(feature = "reactive_stores")]
signal_impl_arena!(Store false);
#[cfg(feature = "reactive_stores")]
signal_impl_arena!(Field false);
signal_impl_arena!(RwSignal false);
signal_impl_arena!(ReadSignal false);
signal_impl_arena!(Memo true);
signal_impl_arena!(Signal true);
signal_impl_arena!(MaybeSignal true);
#[cfg(feature = "reactive_stores")]
signal_impl!(ArcStore false);
#[cfg(feature = "reactive_stores")]
signal_impl!(ArcField false);
signal_impl!(ArcRwSignal false);
signal_impl!(ArcReadSignal false);
Expand Down
Loading

0 comments on commit 5604fa7

Please sign in to comment.