Skip to main content

subscribe_fn

Function subscribe_fn 

Source
pub fn subscribe_fn<F>(
    registry: Arc<SubscriptionRegistry>,
    source_name: String,
    source_id: u32,
    config: SubscriptionConfig,
    f: F,
) -> CallbackSubscriptionHandle
where F: Fn(ChangeEvent) + Send + Sync + 'static,
Expand description

Creates a closure-based subscription (convenience wrapper).

Equivalent to subscribe_callback with a closure wrapped in an internal adapter that implements SubscriptionCallback.

§Example

let handle = subscribe_fn(registry, "trades".into(), 0, config, |event| {
    println!("Got: {:?}", event.event_type());
});