3 releases
0.0.5 | Sep 18, 2022 |
---|---|
0.0.4 | Sep 17, 2022 |
0.0.3 | Sep 17, 2022 |
#37 in #signals
16KB
344 lines
Signals
⚠️ Only Nightly
For calling multiples callbacks.
inspired by QT and godot.
To run a example you need to enter the example that you want to run and type in terminal cargo run
lib.rs
:
Signal
Is a simple signal to connect callbacks
AdvancedSignal
When you connect a callback you can set a other value
AdvanceSignal method is created with macro advanced_method.
advanced_method!{
fn method(|){
}
}
Function with state
use signals_kman::prelude::*;
pub struct State {
a: i32,
}
pub fn main() {
let mut signal = AdvancedSignal::<i32, ()>::new();
let state = State { a: 0 };
signal.connect(&method, vec![Box::new(state)]);
signal.call(1);
signal.call(2);
signal.call(1);
}
advanced_method! {
pub fn method(a: i32|state: State){
state.a += a;
println!("A: {}", state.a);
}
}