1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-05 04:21:03 +02:00

feat(ipc): ironvar list command

This commit is contained in:
Jake Stanger 2024-04-13 23:08:45 +01:00
parent 7e7b3039eb
commit cfaba87f2f
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
4 changed files with 38 additions and 3 deletions

View file

@ -46,6 +46,10 @@ impl VariableManager {
self.variables.get(key).and_then(IronVar::get)
}
pub fn get_all(&self) -> &HashMap<Box<str>, IronVar> {
&self.variables
}
/// Subscribes to an `ironvar`, creating it if it does not exist.
/// Any time the var is set, its value is sent on the channel.
pub fn subscribe(&mut self, key: Box<str>) -> broadcast::Receiver<Option<String>> {
@ -66,7 +70,7 @@ impl VariableManager {
/// Ironbar dynamic variable representation.
/// Interact with them through the `VARIABLE_MANAGER` `VariableManager` singleton.
#[derive(Debug)]
struct IronVar {
pub struct IronVar {
value: Option<String>,
tx: broadcast::Sender<Option<String>>,
_rx: broadcast::Receiver<Option<String>>,
@ -82,7 +86,7 @@ impl IronVar {
/// Gets the current variable value.
/// Prefer to subscribe to changes where possible.
fn get(&self) -> Option<String> {
pub fn get(&self) -> Option<String> {
self.value.clone()
}