Skip to main content

register

Attribute Macro register 

Source
#[register]
Expand description

Registers a subscription to be started with the app.

Put it on the static. It also lets the handler be given as the plain name of an async fn, in place of the boxing closure Subscription::new takes.

#[encore::pubsub::register]
static WELCOME: Subscription<String> =
    Subscription::new(&SIGNUPS, "send-welcome", send_welcome).max_concurrency(4);

async fn send_welcome(msg: Message<String>) -> Result<(), encore::Error> {
    Ok(())
}

See encore::pubsub::register.