Provide a helper method to get selectors from the state

This commit is contained in:
Jeremy Wall 2022-12-26 16:58:41 -05:00
parent 3b220477d7
commit f939f52a2b

View File

@ -63,6 +63,18 @@ where
{
create_effect(cx, move || self.dispatch(message_fn(trigger.get())));
}
pub fn get_selector<F, Val>(
&'ctx self,
cx: Scope<'ctx>,
selector_factory: F,
) -> &'ctx ReadSignal<Val>
where
F: Fn(&'ctx ReadSignal<T>) -> Val + 'ctx,
Val: PartialEq,
{
create_selector(cx, move || selector_factory(self.signal))
}
}
#[cfg(test)]