AppFlowy/rust-lib/flowy-sys/tests/api/helper.rs
appflowy 7e1cf1222f [refactor]:
1. replace unbounded sender with directory call using static runtime
2. sync + send for handler
2021-07-02 20:45:51 +08:00

24 lines
584 B
Rust

use flowy_sys::prelude::*;
use std::{cell::RefCell, sync::Once};
#[allow(dead_code)]
pub fn setup_env() {
static INIT: Once = Once::new();
INIT.call_once(|| {
std::env::set_var("RUST_LOG", "flowy_sys=debug,debug");
env_logger::init();
});
}
pub async fn async_send(data: DispatchRequest<i64>) -> Result<EventResponse, SystemError> {
EventDispatch::async_send(data).await
}
pub fn init_system<F>(module_factory: F)
where
F: FnOnce() -> Vec<Module>,
{
let system = EventDispatch::new(module_factory);
EventDispatch::set_current(system);
}