🚧 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;
|
mod definition;
|
||||||
pub use definition::{action_ref, ActionTrait, AnyAction};
|
pub use definition::{action_ref, ActionTrait, AnyAction};
|
||||||
|
|
||||||
mod bundle;
|
mod list;
|
||||||
pub use bundle::Action;
|
pub use list::Action;
|
||||||
use bundle::ActionsBundle;
|
use list::ActionsList;
|
||||||
|
|
||||||
mod all;
|
mod all;
|
||||||
pub(crate) use all::add_action;
|
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 crate::{Handle, LazyStatic};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
|
|
||||||
// Registered actions.
|
// Registered actions.
|
||||||
static ACTIONS: LazyStatic<RwLock<HashMap<Handle, ActionsBundle>>> =
|
static ACTIONS: LazyStatic<RwLock<HashMap<Handle, ActionsList>>> =
|
||||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||||
|
|
||||||
pub fn add_action(action: Action) {
|
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) {
|
if let Some(bundle) = actions.get_mut(&action_handle) {
|
||||||
bundle.add(action);
|
bundle.add(action);
|
||||||
} else {
|
} 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 {
|
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 {
|
pub fn new_with(action: Action) -> Self {
|
||||||
let mut bundle = ActionsBundle::new();
|
let mut bundle = ActionsList::new();
|
||||||
bundle.add(action);
|
bundle.add(action);
|
||||||
bundle
|
bundle
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue