quickpromise
quickpromise copied to clipboard
Minimal Installation (with just promise.js, PromiseTimer.qml)
Rplaced the code in Minimal Installation...
var promise = new Q.Promise(function(resolve, reject) {
// ...
});
with...
let promise = Q.promise(function(resolve, reject) {
resolve('my promise');
}).then(function(value){
console.log(value);
});
...and added paths of both files into qml.qrc!
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>QuickPromise/promise.js</file>
<file>QuickPromise/PromiseTimer.qml</file>
</qresource>
</RCC>
After this Minimal Installation works with
import QtQuick 2.12
import Qt.labs.platform 1.1
import QtQuick.Controls 2.12
import "./QuickPromise/promise.js" as Q
ApplicationWindow {
visible: true
Rectangle{
visible: true
width: parent.width
height: parent.width
Button{
width: parent.width
height: parent.width
text: "Test"
onClicked: {
console.log("----------- new Q.Promise(function(resolve, reject) ---------------------")
var promise = Q.promise(function(resolve, reject) {
resolve("my promise");
}).then(function(value){
console.log(value);
});
}
}
}
}
When Button 'Test' is pressed, it results in:
qml: ----------- new Q.Promise(function(resolve, reject) ---------------------
qml: my promise
@benlau Please be more clear in Minimal Installation . And replace every 'Q.Promise' with 'Q.promise'.