@@ -1212,9 +1212,9 @@ any( any(p1, p2), any(p3, p4)).then { results in
1212
1212
}
1213
1213
```
1214
1214
1215
- ### Await
1215
+ ### AwaitPromise
1216
1216
1217
- Using ` await ` you can synchronously wait for a promise to get resolved
1217
+ Using ` awaitPromise ` you can synchronously wait for a promise to get resolved
1218
1218
on a different thread. That can be useful for situations when you need
1219
1219
to mix several results from multiple async routines differently, i.e.
1220
1220
cannot chain them in a clear pipeline using [ ` then ` ] ( #then ) ,
@@ -1224,12 +1224,12 @@ Swift:
1224
1224
1225
1225
``` swift
1226
1226
Promise< Int > {
1227
- let minusFive = try await (calculator.negate (5 ))
1228
- let twentyFive = try await (calculator.multiply (minusFive, minusFive))
1229
- let twenty = try await (calculator.add (twentyFive, minusFive))
1230
- let five = try await (calculator.subtract (twentyFive, twenty))
1231
- let zero = try await (calculator.add (minusFive, five))
1232
- return try await (calculator.multiply (zero, five))
1227
+ let minusFive = try awaitPromise (calculator.negate (5 ))
1228
+ let twentyFive = try awaitPromise (calculator.multiply (minusFive, minusFive))
1229
+ let twenty = try awaitPromise (calculator.add (twentyFive, minusFive))
1230
+ let five = try awaitPromise (calculator.subtract (twentyFive, twenty))
1231
+ let zero = try awaitPromise (calculator.add (minusFive, five))
1232
+ return try awaitPromise (calculator.multiply (zero, five))
1233
1233
}.then { result in
1234
1234
// ...
1235
1235
}.catch { error in
@@ -1265,14 +1265,14 @@ Objective-C
1265
1265
Note: In the above examples it's assumed that all calculator routines are
1266
1266
executed asynchronously on a background thread, because the promise work block
1267
1267
is dispatched on a [default queue](#default-dispatch-queue) since no other is
1268
- specified, and so any blocking `await ` would cause a deadlock if it waited for
1268
+ specified, and so any blocking `awaitPromise ` would cause a deadlock if it waited for
1269
1269
a promise that was going to be resolved on the default queue as well. Generally,
1270
- it's usually safer to use `await ` from a global concurrent queue only to avoid
1270
+ it's usually safer to use `awaitPromise ` from a global concurrent queue only to avoid
1271
1271
any potential deadlocks. Like so:
1272
1272
1273
1273
```swift
1274
1274
Promise<Int>(on: .global()) {
1275
- try await (object.someAsyncRoutine())
1275
+ try awaitPromise (object.someAsyncRoutine())
1276
1276
}
1277
1277
```
1278
1278
0 commit comments