rename memo to selector
This commit is contained in:
1 parent
646c161c7d
commit
2c7d0700d4
3 files changed
+5
-5
No files matched your search
@@ -3,7 +3,7 @@ pub use rt::*;
|
|||||||
mod effect;
|
mod effect;
|
||||||
pub use effect::*;
|
pub use effect::*;
|
||||||
mod impls;
|
mod impls;
|
||||||
mod memo;
|
mod selector;
|
||||||
pub use memo::*;
|
pub use selector::*;
|
||||||
pub(crate) mod signal;
|
pub(crate) mod signal;
|
||||||
pub use signal::*;
|
pub use signal::*;
|
||||||
@@ -9,7 +9,7 @@ pub fn use_selector<R: PartialEq>(
|
|||||||
*cx.use_hook(|| selector(f))
|
*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> {
|
let state = Signal::<R> {
|
||||||
inner: CopyValue::invalid(),
|
inner: CopyValue::invalid(),
|
||||||
};
|
};
|
||||||
@@ -26,7 +26,7 @@ fn memos_rerun() {
|
|||||||
let mut signal = use_signal(cx, || 0);
|
let mut signal = use_signal(cx, || 0);
|
||||||
let memo = cx.use_hook(move || {
|
let memo = cx.use_hook(move || {
|
||||||
to_owned![counter];
|
to_owned![counter];
|
||||||
memo(move || {
|
selector(move || {
|
||||||
counter.borrow_mut().effect += 1;
|
counter.borrow_mut().effect += 1;
|
||||||
println!("Signal: {:?}", signal);
|
println!("Signal: {:?}", signal);
|
||||||
signal.value()
|
signal.value()
|
||||||
@@ -102,7 +102,7 @@ fn memos_prevents_component_rerun() {
|
|||||||
|
|
||||||
let memo = cx.use_hook(move || {
|
let memo = cx.use_hook(move || {
|
||||||
to_owned![counter];
|
to_owned![counter];
|
||||||
memo(move || {
|
selector(move || {
|
||||||
counter.borrow_mut().effect += 1;
|
counter.borrow_mut().effect += 1;
|
||||||
println!("Signal: {:?}", signal);
|
println!("Signal: {:?}", signal);
|
||||||
signal.value()
|
signal.value()
|
||||||
Reference in new issue
Block a user