Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. var isGettingGroup = false
  2. func getGroup(completion: (group?, error?)) {
  3.  
  4. if isGettingGroup {
  5. wait for notification
  6. }
  7. if let group = groupFromCache() {
  8. completion(group, nil)
  9. } else {
  10. isGettingGroup = true
  11. callGetGroupAPI() { group, error in
  12. completion(group, error)
  13. cacheGroup(group)
  14. isGettingGroup = false
  15. send notification to continue
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement