AppFlowy/frontend/rust-lib/flowy-grid/src/event_map.rs

34 lines
1016 B
Rust
Raw Normal View History

2022-03-02 14:43:04 +00:00
use crate::event_handler::*;
2022-03-04 14:09:16 +00:00
use crate::manager::GridManager;
2022-03-02 14:43:04 +00:00
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
use lib_dispatch::prelude::*;
use std::sync::Arc;
use strum_macros::Display;
pub fn create(grid_manager: Arc<GridManager>) -> Module {
let mut module = Module::new().name(env!("CARGO_PKG_NAME")).data(grid_manager);
module = module
2022-03-03 14:17:07 +00:00
.event(GridEvent::OpenGrid, open_grid_handler)
.event(GridEvent::GetRows, get_rows_handler)
.event(GridEvent::GetFields, get_fields_handler)
.event(GridEvent::CreateRow, create_row_handler);
2022-03-02 14:43:04 +00:00
module
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
#[event_err = "FlowyError"]
pub enum GridEvent {
#[event(input = "GridId", output = "Grid")]
2022-03-05 02:59:44 +00:00
OpenGrid = 0,
2022-03-03 14:17:07 +00:00
#[event(input = "RepeatedRowOrder", output = "RepeatedRow")]
2022-03-05 02:59:44 +00:00
GetRows = 1,
2022-03-03 14:17:07 +00:00
#[event(input = "RepeatedFieldOrder", output = "RepeatedField")]
2022-03-05 02:59:44 +00:00
GetFields = 2,
2022-03-03 14:17:07 +00:00
#[event(input = "GridId")]
2022-03-05 02:59:44 +00:00
CreateRow = 3,
2022-03-02 14:43:04 +00:00
}