Releases: benlau/quickfuture
v1.0.6 Release
New API
- Future.progressValue
- Future.progressMaximum
- Future.progressMinimum
Changes
- Future.result()
[Bug Fix] Prevent crash on getting the result of QFuture<void>
- Future.promise()
Reject the returned promise if the QFuture is canceled.
- Future.onProgressValueChanged
[Bug Fix] The signal will only be emitted once
v1.0.3 Release
New Features
Custom Converter function
QuickFuture::registerType()
now supports to assign a custom converter for making a QML friendly data structure (e.g QVariantMap) from the custom type. The value could be obtained by using Future.result()
class Actor : public QObject {
Q_OBJECT
public:
class Reply {
public:
int code;
QString message;
};
QFuture<Reply> read(QString source);
}
static void init() {
QuickFuture::registerType<Actor::Reply>([](Actor::Reply reply) -> QVariant {
// Optional converter function.
QVariantMap map;
map["code"] = reply.code;
map["message"] = reply.message;
return map;
});
}
Q_COREAPP_STARTUP_FUNCTION(init)
var future = Actor.read(source);
....
console.log(Future.result(future)); // Print { code: 0, message: ""} if the reply is empty
v1.0.2 Release
Critical Changes
- The QML package name has been changed from
Future
toQuickFuture
import QuickFuture 1.0
- Type registration is done by
QuickFuture::registerType
instead ofQFFuture::registerType
#include <QuickFuture>
Q_DECLARE_METATYPE(QFuture<CustomType>)
...
int main(int argc, char *argv[])
{
...
QuickFuture::registerType<CustomType>();
...
}
New API
Future.isRunning(future)
Future.isCanceled(future)
Future.onCanceled(future, callback)
Future.result(future)
Future.sync(future, propertyAtFuture, target, propertyAtTarget)
Synchronize a property in future object to target object.
Example:
QtObject {
id: target1
property var isRunning
property var isFinished
}
// Future.sync(future,"isRunning", target1, "isRunning");
// Future.sync(future,"isFinished", target1);
Supported properties: "isRunning", "isCanceled", "isFinished"
v1.0 Release
API
Future.isFinished(future)
Returns true if the asynchronous computation represented by this future has finished; otherwise returns false.
Future.onFinished(future, callback)
The callback will be invoked when the watched future finishes.
Future.promise(future)
Create a promise object which will be resolved when the future has finished. It must have QuickPromise installed and setup properly before using this function.