🚧 Retoques con la lista de acciones
This commit is contained in:
parent
9a63cacd8f
commit
8eba48283e
3 changed files with 10 additions and 10 deletions
|
|
@ -1,9 +1,9 @@
|
|||
mod definition;
|
||||
pub use definition::{action_ref, ActionTrait, AnyAction};
|
||||
|
||||
mod bundle;
|
||||
pub use bundle::Action;
|
||||
use bundle::ActionsBundle;
|
||||
mod list;
|
||||
pub use list::Action;
|
||||
use list::ActionsList;
|
||||
|
||||
mod all;
|
||||
pub(crate) use all::add_action;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use crate::core::action::{Action, ActionsBundle};
|
||||
use crate::core::action::{Action, ActionsList};
|
||||
use crate::{Handle, LazyStatic};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::RwLock;
|
||||
|
||||
// Registered actions.
|
||||
static ACTIONS: LazyStatic<RwLock<HashMap<Handle, ActionsBundle>>> =
|
||||
static ACTIONS: LazyStatic<RwLock<HashMap<Handle, ActionsList>>> =
|
||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||
|
||||
pub fn add_action(action: Action) {
|
||||
|
|
@ -14,7 +14,7 @@ pub fn add_action(action: Action) {
|
|||
if let Some(bundle) = actions.get_mut(&action_handle) {
|
||||
bundle.add(action);
|
||||
} else {
|
||||
actions.insert(action_handle, ActionsBundle::new_with(action));
|
||||
actions.insert(action_handle, ActionsList::new_with(action));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ macro_rules! action {
|
|||
}};
|
||||
}
|
||||
|
||||
pub struct ActionsBundle(Arc<RwLock<Vec<Action>>>);
|
||||
pub struct ActionsList(Arc<RwLock<Vec<Action>>>);
|
||||
|
||||
impl ActionsBundle {
|
||||
impl ActionsList {
|
||||
pub fn new() -> Self {
|
||||
ActionsBundle(Arc::new(RwLock::new(Vec::new())))
|
||||
ActionsList(Arc::new(RwLock::new(Vec::new())))
|
||||
}
|
||||
|
||||
pub fn new_with(action: Action) -> Self {
|
||||
let mut bundle = ActionsBundle::new();
|
||||
let mut bundle = ActionsList::new();
|
||||
bundle.add(action);
|
||||
bundle
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue