pub struct HxResponseTrigger {
pub timing: TriggerTiming,
pub events: Vec<HxEvent>,
}Expand description
Triggers client-side events via one of the HX-Trigger response headers.
When every event has no detail, the header is a comma-separated list of
names. As soon as one event carries data, the whole header is serialized as
a JSON object mapping each event name to its detail (or null).
§Examples
use topcoat::htmx::{HxEvent, HxResponseTrigger};
// `HX-Trigger: refresh, close-modal`
let simple = HxResponseTrigger::receive(["refresh", "close-modal"]);
// JSON form, fired after the swap step.
let detailed =
HxResponseTrigger::after_swap([HxEvent::with_data("show-toast", "Saved!").unwrap()]);Fields§
§timing: TriggerTimingWhen the events fire.
events: Vec<HxEvent>The events to trigger.
Implementations§
Source§impl HxResponseTrigger
impl HxResponseTrigger
Sourcepub fn new(
timing: TriggerTiming,
events: impl IntoIterator<Item = impl Into<HxEvent>>,
) -> Self
pub fn new( timing: TriggerTiming, events: impl IntoIterator<Item = impl Into<HxEvent>>, ) -> Self
Triggers events with the given timing.
Sourcepub fn receive(events: impl IntoIterator<Item = impl Into<HxEvent>>) -> Self
pub fn receive(events: impl IntoIterator<Item = impl Into<HxEvent>>) -> Self
Triggers events as soon as the response is received (HX-Trigger).
Sourcepub fn after_settle(
events: impl IntoIterator<Item = impl Into<HxEvent>>,
) -> Self
pub fn after_settle( events: impl IntoIterator<Item = impl Into<HxEvent>>, ) -> Self
Triggers events after the settle step (HX-Trigger-After-Settle).
Sourcepub fn after_swap(events: impl IntoIterator<Item = impl Into<HxEvent>>) -> Self
pub fn after_swap(events: impl IntoIterator<Item = impl Into<HxEvent>>) -> Self
Triggers events after the swap step (HX-Trigger-After-Swap).
Trait Implementations§
Source§impl Clone for HxResponseTrigger
impl Clone for HxResponseTrigger
Source§fn clone(&self) -> HxResponseTrigger
fn clone(&self) -> HxResponseTrigger
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HxResponseTrigger
impl Debug for HxResponseTrigger
impl Eq for HxResponseTrigger
Source§impl PartialEq for HxResponseTrigger
impl PartialEq for HxResponseTrigger
impl StructuralPartialEq for HxResponseTrigger
Auto Trait Implementations§
impl Freeze for HxResponseTrigger
impl RefUnwindSafe for HxResponseTrigger
impl Send for HxResponseTrigger
impl Sync for HxResponseTrigger
impl Unpin for HxResponseTrigger
impl UnsafeUnpin for HxResponseTrigger
impl UnwindSafe for HxResponseTrigger
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
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.