pub struct UseSorter<'a, F: 'static> { /* private fields */ }Expand description
Stores Dioxus hooks and state of our sortable items.
Implementations§
Source§impl<'a, F> UseSorter<'a, F>
impl<'a, F> UseSorter<'a, F>
Sourcepub fn get_state(&self) -> (&F, &Direction)
pub fn get_state(&self) -> (&F, &Direction)
Returns the current field and direction. Can be used to recreate state with UseSorterBuilder.
Sourcepub fn toggle_field(&self, field: F)where
F: Sortable,
pub fn toggle_field(&self, field: F)where
F: Sortable,
Sets the sort field and toggles the direction (if applicable). Ignores unsortable fields.
Sourcepub fn set_field(&self, field: F, dir: Direction)where
F: Sortable,
pub fn set_field(&self, field: F, dir: Direction)where
F: Sortable,
Sets the sort field and direction state directly. Ignores unsortable fields. Ignores the direction if not valid for a field.
Sourcepub fn sort<T>(&self, items: &mut [T])where
F: PartialOrdBy<T> + Sortable,
pub fn sort<T>(&self, items: &mut [T])where
F: PartialOrdBy<T> + Sortable,
Sorts items according to the current field and direction.
This is not a hook and may be called conditionally. For example:
- If data is coming from a
use_futurethen you can call this fn once it has completed. - If you need to apply a filter, do so before calling this fn.
Trait Implementations§
impl<'a, F: Copy + 'static> Copy for UseSorter<'a, F>
impl<'a, F: 'static> StructuralPartialEq for UseSorter<'a, F>
Auto Trait Implementations§
impl<'a, F> Freeze for UseSorter<'a, F>
impl<'a, F> !RefUnwindSafe for UseSorter<'a, F>
impl<'a, F> !Send for UseSorter<'a, F>
impl<'a, F> !Sync for UseSorter<'a, F>
impl<'a, F> Unpin for UseSorter<'a, F>
impl<'a, F> !UnwindSafe for UseSorter<'a, F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more