pub fn use_input_selector_value<'hook, T>(
    input: Rc<T::Input>
) -> impl 'hook + Hook<Output = Rc<T>>
where T: InputSelector + 'static + 'hook,
Expand description

A hook to connect to an InputSelector.

An input selector is similar to a selector, but also with an input.

Its value will be automatically re-calculated when any state used in the selector has changed.

Returns a Rc<T>.

Example

#[derive(Default, PartialEq, Slice)]
struct Value(i64);

#[derive(PartialEq)]
pub struct DivBy {
    inner: bool,
}

impl InputSelector for DivBy {
    type Input = i64;

    fn select(states: &BounceStates, input: Rc<Self::Input>) -> Rc<Self> {
        let val = states.get_slice_value::<Value>();

        Self {
            inner: val.0 % *input == 0,
        }
        .into()
    }
}
let is_even = use_input_selector_value::<DivBy>(2.into());

Note

When used in function components and hooks, this hook is equivalent to:

pub fn use_input_selector_value<T>(input: Rc<T::Input>) -> Rc<T>
where
    T: InputSelector + 'static,
{
    /* implementation omitted */
}