2. 1. Callback hell & Another problem
2. What is promise ?
3. Chaining tasks pattern
4. Parallel tasks pattern
5. Errors handler
6. Example with Bolt Framework
7. Advantages
Agenda
Future/Promise on iOS
2
7. Callback hell & Another problems
Future/Promise on iOS
7
How could I call 3 requests on same times?
8. Callback hell & Another problems
Future/Promise on iOS
8
Hard to understand
and follow the logic ?
What happen when
1 request has error?
9. What is promise ?
Future/Promise on iOS
9
• Deferred State
• pending
• Settled State
• fulfilled
• rejected
10. What is promise ? - fulfilled
Future/Promise on iOS
10
fulfilled could be
•Value
•Object
•Another Promise
11. What is promise ? - rejected
Future/Promise on iOS
11
rejected could be
•Error
12. Chaining tasks pattern
Future/Promise on iOS
12
• continueWith: Enqueues a given closure
to be run once this task is complete.
• continueWithTask: This is the method that
all other continuations must go through.
• continueOnSuccessWith
(continueOnSuccessWithTask): Enqueues
a given closure to be run once this task
completes with success (has intended
result).
• continueOnErrorWith
(continueOnErrorWithTask): Enqueues a
given closure to be run once this task
completes with error.
18. Parallel tasks pattern
Future/Promise on iOS
18
• whenAll : Creates a task that will be completed
after all of the input tasks have completed.
• whenAllResult: Like whenAll. The result of the
task is going an array of results of all tasks in the
same order as they were provided.
• whenAny: Creates a task that will complete when
any of the input tasks have completed.
23. Could only go with tasks on function
•continueWith
•continueOnErrorWith
If error occurs next task on
continueOnSuccessWith will never run
Errors handler
Future/Promise on iOS
23
24. • How to create Promise from
Asynchronous function
• How to create Promise from Synchronous
function
BoltFramework
Future/Promise on iOS
24