- // Now we are read for the demo.
- pub fn demo() {
- let mut c = Callbacks::new();
- c.register(Box::new(|val| println!("Callback 1: {}", val)));
-
- c.call(0);
-
- let mut count: usize = 0;
- c.register(Box::new(move |val| { count = count+1; println!("Callback 2, {}. time: {}", count, val); } ));
- c.call(1);
- c.call(2);
+ // Registration simply stores the callback.
+ pub fn register(&mut self, callback: Box<FnMut(i32)>) {
+ self.callbacks.push(callback);