use futures::{
channel::mpsc::{UnboundedReceiver, UnboundedSender},
StreamExt,
};
use crate::GuardCondition;
pub(super) enum NodeGraphAction {
NewGraphListener(UnboundedSender<()>),
GraphChange,
}
pub(super) async fn node_graph_task(
mut receiver: UnboundedReceiver<NodeGraphAction>,
#[allow(unused)] guard_condition: GuardCondition,
) {
let mut listeners = Vec::new();
while let Some(action) = receiver.next().await {
match action {
NodeGraphAction::NewGraphListener(listener) => {
if listener.unbounded_send(()).is_ok() {
listeners.push(listener);
}
}
NodeGraphAction::GraphChange => {
listeners.retain(|listener| listener.unbounded_send(()).is_ok());
}
}
}
}