Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
Add document of observe(QFuture<QFuture<T>>)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlau committed Dec 28, 2017
1 parent 62314df commit 24a0130
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,35 @@ observe(future).subscribe([](bool toggled) {
});
```
AsyncFuture::observe(QFuture&lt;QFuture&lt;T&gt;T&gt; future)
-----
This function creates an Observable<T> object which provides an interface for observing the input future. That is designed to handle following use-case:
```
QFuture<QImage> readImagesFromFolder(const QString& folder) {

auto worker = [=]() {
// Read files from a directory in a thread
QStringList files = findImageFiles(folder);

// Concurrent image reader
return QtConcurrent::mapped(files, readImage);
};

auto future = QtConcurrent::run(worker); // The type of future is QFuture<QFuture<QImage>>

auto defer = AsyncFuture::deferred<QImage>();

// defer object track the input future. It will emit "started" and `progressValueChanged` according to the status of the future of "QtConcurrent::mapped"
defer.complete(future);
return defer.future();
}
```
See [Observable`<T>`](#observablet)
AsyncFuture::combine(CombinatorMode mode = FailFast)
------------
Expand Down
2 changes: 1 addition & 1 deletion qpm.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "[email protected]:benlau/asyncfuture.git"
},
"version": {
"label": "0.3.6.5",
"label": "0.4.0",
"revision": "",
"fingerprint": ""
},
Expand Down

0 comments on commit 24a0130

Please sign in to comment.