Skip to content

Releases: benlau/quickfuture

v1.0.6 Release

29 Apr 17:12
Compare
Choose a tag to compare

New API

  1. Future.progressValue
  2. Future.progressMaximum
  3. Future.progressMinimum

Changes

  1. Future.result()

[Bug Fix] Prevent crash on getting the result of QFuture<void>

  1. Future.promise()

Reject the returned promise if the QFuture is canceled.

  1. Future.onProgressValueChanged

[Bug Fix] The signal will only be emitted once

v1.0.3 Release

25 Apr 18:38
Compare
Choose a tag to compare

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

20 Apr 05:47
Compare
Choose a tag to compare

Critical Changes

  1. The QML package name has been changed from Future to QuickFuture
import QuickFuture 1.0
  1. Type registration is done by QuickFuture::registerType instead of QFFuture::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

21 Oct 05:28
Compare
Choose a tag to compare

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.