wip: refactor

This commit is contained in:
2024-12-19 09:46:22 +07:00
parent 407db7a7d5
commit f800a27aef
11 changed files with 328 additions and 239 deletions

View File

@@ -0,0 +1,32 @@
use gpui::*;
use nostr_sdk::prelude::*;
use std::sync::Arc;
use tokio::sync::mpsc::UnboundedSender;
#[derive(Clone)]
pub enum Signal {
/// Request metadata
ReqMetadata(PublicKey),
/// Receive metadata
RecvMetadata(PublicKey),
/// Receive EOSE
RecvEose(SubscriptionId),
/// Receive event
RecvEvent(Event),
}
pub struct SignalRegistry {
pub tx: Arc<UnboundedSender<PublicKey>>,
}
impl Global for SignalRegistry {}
impl SignalRegistry {
pub fn set_global(cx: &mut AppContext, tx: UnboundedSender<PublicKey>) {
cx.set_global(Self::new(tx));
}
fn new(tx: UnboundedSender<PublicKey>) -> Self {
Self { tx: Arc::new(tx) }
}
}