use once_cell::sync::Lazy;
use std::sync::Arc;
use tokio::sync::broadcast;

use super::event_bus::EventBus;
use crate::watcher::WatcherCommand;

static WATCHER_CHANNEL: Lazy<Arc<EventBus<WatcherCommand>>> = Lazy::new(|| Arc::new(EventBus::new()));
pub fn publish_watcher_event(event: WatcherCommand) {
  WATCHER_CHANNEL.publish(event);
}

pub fn subscribe_watcher_event() -> broadcast::Receiver<WatcherCommand> {
  WATCHER_CHANNEL.subscribe()
}
