Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var isGettingGroup = false
- func getGroup(completion: (group?, error?)) {
- if isGettingGroup {
- wait for notification
- }
- if let group = groupFromCache() {
- completion(group, nil)
- } else {
- isGettingGroup = true
- callGetGroupAPI() { group, error in
- completion(group, error)
- cacheGroup(group)
- isGettingGroup = false
- send notification to continue
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement