From 2d401b7685e6f142c5945075ba2d79abfa781f49 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 6 Sep 2014 17:51:16 -0400 Subject: add a basic runloop --- src/client.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/client.rs b/src/client.rs index 2824df2..3beda7d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -133,4 +133,16 @@ impl Client { None => None, } } + + // XXX eventually, we'll want to set up callbacks for specific events + // beforehand, and just have a `run_loop` method that loops and calls the + // preset callbacks as necessary. unfortunately, rust doesn't handle + // storing closures very well yet if they need to receive a borrowed + // pointer, and we would need to pass the client object into the callback + // in order to make this work + pub fn run_loop_with (&mut self, handler: |Message|) { + loop { + handler(self.read()); + } + } } -- cgit v1.2.3