xq_notification

Crates.ioxq_notification
lib.rsxq_notification
version0.0.1
sourcesrc
created_at2021-10-29 09:29:55.91061
updated_at2021-10-29 09:29:55.91061
description通知的封装
homepagehttps://github.com/SyKingW/xq-notification-rs
repository
max_upload_size
id473875
size10,157
普通上班族老王 (SyKingW)

documentation

README

xq-notification-rs

rust 通知封装

使用介绍

Cargo.toml

serde_json = "^1.0"
xq_notification = "*"

示例代码

use std::{thread};
use xq_notification::notification::NotificationManager;
use serde_json;

fn main() {
    // 第一个通知
    thread::spawn(move || match NotificationManager::observe("test") {
        Some(r) => loop {
            match r.recv() {
                Ok(_) => {
                    // 接收到通知
                }
                Err(_) => {
                    break;
                }
            }
        },
        None => {}
    }); 

    // 第二个通知
    thread::spawn(move || match NotificationManager::observe("test") {
        Some(r) => loop {
            match r.recv() {
                Ok(_) => {
                    // 接收到通知
                }
                Err(_) => {
                    break;
                }
            }
        },
        None => {}
    });

    // 发送通知
    for i in 0..10000 {
        NotificationManager::publish("test", serde_json::Value::String(format!("{}", i)));
    }

}
Commit count: 0

cargo fmt