rename memo to selector

This commit is contained in:
Evan Almloff committed 2023-08-07 16:17:47 -07:00
1 parent 646c161c7d
commit 2c7d0700d4
3 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -3,7 +3,7 @@ pub use rt::*;
mod effect;
pub use effect::*;
mod impls;
mod memo;
pub use memo::*;
mod selector;
pub use selector::*;
pub(crate) mod signal;
pub use signal::*;
@@ -9,7 +9,7 @@ pub fn use_selector<R: PartialEq>(
*cx.use_hook(|| selector(f))
}
fn selector<R: PartialEq>(mut f: impl FnMut() -> R + 'static) -> ReadOnlySignal<R> {
pub fn selector<R: PartialEq>(mut f: impl FnMut() -> R + 'static) -> ReadOnlySignal<R> {
let state = Signal::<R> {
inner: CopyValue::invalid(),
};
@@ -26,7 +26,7 @@ fn memos_rerun() {
let mut signal = use_signal(cx, || 0);
let memo = cx.use_hook(move || {
to_owned![counter];
memo(move || {
selector(move || {
counter.borrow_mut().effect += 1;
println!("Signal: {:?}", signal);
signal.value()
@@ -102,7 +102,7 @@ fn memos_prevents_component_rerun() {
let memo = cx.use_hook(move || {
to_owned![counter];
memo(move || {
selector(move || {
counter.borrow_mut().effect += 1;
println!("Signal: {:?}", signal);
signal.value()