mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix init folder manager bugs
This commit is contained in:
@ -3,7 +3,6 @@ use crate::{
|
||||
module::{as_module_map, Module, ModuleMap, ModuleRequest},
|
||||
response::EventResponse,
|
||||
service::{Service, ServiceFactory},
|
||||
util::tokio_default_runtime,
|
||||
};
|
||||
use derivative::*;
|
||||
use futures_core::future::BoxFuture;
|
||||
@ -17,11 +16,10 @@ pub struct EventDispatcher {
|
||||
}
|
||||
|
||||
impl EventDispatcher {
|
||||
pub fn construct<F>(module_factory: F) -> EventDispatcher
|
||||
pub fn construct<F>(runtime: tokio::runtime::Runtime, module_factory: F) -> EventDispatcher
|
||||
where
|
||||
F: FnOnce() -> Vec<Module>,
|
||||
{
|
||||
let runtime = tokio_default_runtime().unwrap();
|
||||
let modules = module_factory();
|
||||
tracing::trace!("{}", module_info(&modules));
|
||||
let module_map = as_module_map(modules);
|
||||
|
@ -3,7 +3,7 @@ mod module;
|
||||
mod request;
|
||||
mod response;
|
||||
mod service;
|
||||
mod util;
|
||||
pub mod util;
|
||||
|
||||
mod byte_trait;
|
||||
mod data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use lib_dispatch::prelude::*;
|
||||
use lib_dispatch::{prelude::*, util::tokio_default_runtime};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub async fn hello() -> String { "say hello".to_string() }
|
||||
@ -8,7 +8,10 @@ async fn test() {
|
||||
env_logger::init();
|
||||
|
||||
let event = "1";
|
||||
let dispatch = Arc::new(EventDispatcher::construct(|| vec![Module::new().event(event, hello)]));
|
||||
let runtime = tokio_default_runtime().unwrap();
|
||||
let dispatch = Arc::new(EventDispatcher::construct(runtime, || {
|
||||
vec![Module::new().event(event, hello)]
|
||||
}));
|
||||
let request = ModuleRequest::new(event);
|
||||
let _ = EventDispatcher::async_send_with_callback(dispatch.clone(), request, |resp| {
|
||||
Box::pin(async move {
|
||||
|
Reference in New Issue
Block a user