You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`complexFunc` is a function that returns the result of three simple, asynchronous functions `simpleFuncA()`, `simpleFuncB()`, and `simpleFuncC()`, which run concurrently. The completion handler is called only when all the simple functions have completed. Usage of this library has enabled the above clean interface. This can be scaled to much higher than three simple functions.
89
+
`complexFunc` is a function that returns the result of three asynchronous functions `asyncFuncA()`, `asyncFuncB()`, and `asyncFuncC()`, running concurrently. The completion handler is called only when all these functions have completed. Usage of this library has enabled the above clean interface. This can be scaled to much higher than three asynchronous functions.
82
90
83
-
Caveats:
84
-
- the simple functions MUST be able to run simultaneously without affecting each other
91
+
notes:
92
+
- the asynchronous functions should be able to run concurrently without affecting each other
85
93
-`work.result` is only a simple `Bool`
86
94
- this is not an answer to [callback hell](http://callbackhell.com/)
87
95
@@ -93,21 +101,21 @@ There is some set up required in order to create `complexFunc()` from above:
93
101
importGroupWork
94
102
95
103
extensionGroupWork {
96
-
funcsimplefuncA() {
104
+
funcasyncFuncA() {
97
105
start()
98
106
networkCallA() { (result)
99
107
self.finish(withResult: result)
100
108
}
101
109
}
102
110
103
-
funcsimplefuncB() {
111
+
funcasyncFuncB() {
104
112
start()
105
113
networkCallB() { (result)
106
114
self.finish(withResult: result)
107
115
}
108
116
}
109
117
110
-
funcsimplefuncC() {
118
+
funcasyncFuncC() {
111
119
start()
112
120
networkCallC() { (result)
113
121
self.finish(withResult: result)
@@ -118,14 +126,14 @@ extension GroupWork {
118
126
119
127
Now you can create a `GroupWork`, and call `work.simpleFuncA()` on it like in the example.
120
128
121
-
Caveats:
122
-
-notice that in each function, `start()`is called before each asynchronous task
123
-
-`finish(withResult:)`is called in the completion handler of each asynchronous task
124
-
-`start()` and `finish()` calls MUST be balanced
129
+
notes:
130
+
-`start()`must be called before an asynchronous task
131
+
-`finish()`must be called in the completion handler of an asynchronous
132
+
-`start()` and `finish()` calls must be balanced
125
133
126
134
## Working Example
127
135
128
-
The [tests]() have a working example.
136
+
The [tests](GroupWorkTests/GroupWorkTests.swift) have a working example.
0 commit comments