From f939f52a2bf03a2aada350853012001917580276 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 26 Dec 2022 16:58:41 -0500 Subject: [PATCH] Provide a helper method to get selectors from the state --- src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index b73d172..180c70d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,6 +63,18 @@ where { create_effect(cx, move || self.dispatch(message_fn(trigger.get()))); } + + pub fn get_selector( + &'ctx self, + cx: Scope<'ctx>, + selector_factory: F, + ) -> &'ctx ReadSignal + where + F: Fn(&'ctx ReadSignal) -> Val + 'ctx, + Val: PartialEq, + { + create_selector(cx, move || selector_factory(self.signal)) + } } #[cfg(test)]