Commit b19e05ab authored by Avi's avatar Avi

First nested cheesecake() inside Gio.File.prototype.load_contents_promise()

parent 65502954
......@@ -3,29 +3,42 @@ const cancel = new Gio.Cancellable();
let loop = GLib.MainLoop.new(null, false);
const cheesecake = (file, cancellable = null)=>{
return new Promise((resolve, reject)=>{
file.load_contents_async(cancellable, function(f, res) {
try {
let result = f.load_contents_finish(res);
resolve(result);
} catch (error) {
reject(error);
}
});
});
};
// const cheesecake = (file, cancellable = null)=>{
// return new Promise((resolve, reject)=>{
// file.load_contents_async(cancellable, function(f, res) {
// try {
// let result = f.load_contents_finish(res);
// resolve(result);
// } catch (error) {
// reject(error);
// }
// });
// });
// };
/* This is a workaround for now */
const Gio_File_prototype = Gio.File.new_for_path('').constructor.prototype;
Gio_File_prototype.load_contents_promise = function(cancellable){
// return cheesecake(this, cancellable);
const cheesecake = (file, cancellable = null)=>{
return new Promise((resolve, reject)=>{
file.load_contents_async(cancellable, function(f, res) {
try {
let result = f.load_contents_finish(res);
resolve(result);
} catch (error) {
reject(error);
}
});
});
};
return cheesecake(this, cancellable);
}
/* This is what it should be once the bug is fixed! */
// Gio.File.prototype.load_contents_promise = function(cancellable){
// return cheesecake(this, cancellable);
// }
Gio.File.prototype.load_contents_promise = function(cancellable){
return cheesecake(this, cancellable);
}
const head = async(filename)=>{
let file = Gio.file_new_for_commandline_arg(filename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment