Differential D18758 Diff 58398 kdevplatform/3rdparty/qtpromise/qtpromise-0.5.0/docs/qtpromise/qpromise/finally.md
Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/3rdparty/qtpromise/qtpromise-0.5.0/docs/qtpromise/qpromise/finally.md
- This file was added.
1 | --- | ||||
---|---|---|---|---|---|
2 | title: .finally | ||||
3 | --- | ||||
4 | | ||||
5 | # QPromise::finally | ||||
6 | | ||||
7 | *Since: 0.1.0* | ||||
8 | | ||||
9 | ```cpp | ||||
10 | QPromise<T>::finally(Function handler) -> QPromise<T> | ||||
11 | ``` | ||||
12 | | ||||
13 | This `handler` is **always** called, without any argument and whatever the `input` promise state (fulfilled or rejected). The `output` promise has the same type as the `input` one but also the same value or error. The finally `handler` **can not modify the fulfilled value** (the returned value is ignored), however, if `handler` throws, `output` is rejected with the new exception. | ||||
14 | | ||||
15 | ```cpp | ||||
16 | auto output = input.finally([]() { | ||||
17 | // {...} | ||||
18 | }); | ||||
19 | ``` | ||||
20 | | ||||
21 | If `handler` returns a promise (or QFuture), the `output` promise is delayed until the returned promise is resolved and under the same conditions: the delayed value is ignored, the error transmitted to the `output` promise. |