pub struct WatchHandler<T, ST> { /* private fields */ }
Expand description
Handler for hanging gets.
The common way to use this is to implement the Sender
Implementations§
Source§impl<T, ST> WatchHandler<T, ST>
impl<T, ST> WatchHandler<T, ST>
Sourcepub fn create(initial_value: Option<T>) -> Self
pub fn create(initial_value: Option<T>) -> Self
Creates a new instance of WatchHandler. If |initial_value| is provided, it will return immediately on first watch. Otherwise, the first watch returns when the value is set for the first time. Uses default change function which just checks for any change.
Source§impl<T, ST> WatchHandler<T, ST>
impl<T, ST> WatchHandler<T, ST>
Sourcepub fn create_with_change_fn(
change_function: Box<dyn Fn(&T, &T) -> bool + Send + Sync + 'static>,
initial_value: Option<T>,
) -> Self
pub fn create_with_change_fn( change_function: Box<dyn Fn(&T, &T) -> bool + Send + Sync + 'static>, initial_value: Option<T>, ) -> Self
Creates a new instance of WatchHandler. If |initial_value| is provided, it will return immediately on first watch. Otherwise, the first watch returns when the value is set for the first time.
Sourcepub fn watch(&mut self, responder: ST) -> Result<(), WatchError<ST>>
pub fn watch(&mut self, responder: ST) -> Result<(), WatchError<ST>>
Park a new hanging get in the handler. If a hanging get is already parked, returns the new responder.
Sourcepub fn set_change_function(
&mut self,
change_function: Box<dyn Fn(&T, &T) -> bool + Send + Sync + 'static>,
)
pub fn set_change_function( &mut self, change_function: Box<dyn Fn(&T, &T) -> bool + Send + Sync + 'static>, )
Sets a new change function. The hanging get will only return when the change function evaluates to true when comparing the last value sent to the client and the current value. Takes effect immediately; if change function evaluates to true then the pending responder will be called.