Update CommonPatterns.md

This commit is contained in:
Max Howell 2019-09-04 14:01:49 -04:00 committed by GitHub
parent 4d8d1287d2
commit 08fb076071
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -186,12 +186,14 @@ fade.done {
}
```
Or if you have an array of promises:
Or if you have an array of closures that return promises:
```swift
var foo = Promise()
for nextPromise in arrayOfPromises {
foo = foo.then { nextPromise }
for nextPromise in arrayOfClosuresThatReturnPromises {
foo = foo.then(nextPromise)
// ^^ you rarely would want an array of promises instead, since then
// they have all already started, you may as well use `when()`
}
foo.done {
// finish