Slide 30
Slide 30 text
GIO Async operations
● Outreachy project of Avi Zajac (llzes)
● Intended to land in 3.32
● If you pass a callback to GIO async
methods, you'll get the C-style callback API
as usual
● If you omit the callback, you'll get a
Promise
● Promises work transparently with async
functions and await expressions
● Support for annotations in
gobject-introspection to benefit other
languages
try {
let [contents] =
await file.load_contents_async(null);
print(contents);
let info = await file.query_info_async(
'standard::*',
Gio.FileQueryInfoFlags.NONE,
GLib.PRIORITY_DEFAULT, null);
print(info.get_size(), 'bytes');
} catch (e) {
logError(e, 'Oh no!');
} finally {
loop.quit();
}