[][src]Macro vgtk::stream_signal

macro_rules! stream_signal {
    ($object:expr, $connect:ident) => { ... };
}

Connect a GLib signal to a Stream.

This macro takes a GLib object and the name of a method to connect it to a signal (generally of the form connect_signal_name), and generates a Stream that will produce a value every time the signal is emitted.

The output type of the stream is the type of the emitted value (the second argument to the callback connect_signal_name takes). The stream will terminate when the object it's connected to is destroyed.

Note that this only works with connect_* callbacks which take two arguments. The second argument will be the contents of the stream. The first argument, normally a reference to the signal's sender, is ignored.

Examples

let dialog = AboutDialog::new();
dialog.set_program_name("Frobnicator");
dialog.show();
stream_signal!(dialog, connect_response).for_each(|response| {
    println!("Dialog response: {:?}", response);
    future::ready(())
});