Skip to content
Discussion options

You must be logged in to vote

Thanks. My working example.

use axum::{
    Router,
    routing::get,
    response::sse::{Event, KeepAlive, Sse},
    extract::State,
};
use tower_http::services::ServeDir;

use std::path::Path;
use futures_util::stream::Stream;

use notify::{Watcher, RecursiveMode, Result as NResult};

use tokio::sync::broadcast;
use tokio_stream::wrappers::{BroadcastStream, errors::BroadcastStreamRecvError};

#[derive(Clone)]
struct AppState {
    // Channel used to send messages to all connected clients.
    tx: broadcast::Sender<Event>,
}

#[tokio::main]
async fn main() {

    let (tx, _) = broadcast::channel::<Event>(100);
    let app_state = AppState{tx: tx.clone()};

    // file change notification…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@ekanna
Comment options

Answer selected by ekanna
Comment options

You must be logged in to vote
1 reply
@ekanna
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants