Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Update unsubscribe to remove subscriptions from the tracked subscript…
Browse files Browse the repository at this point in the history
…ions list (#139)
  • Loading branch information
JoeSzymanski authored and flovilmart committed Dec 9, 2017
1 parent b039624 commit 8715b15
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/ParseLiveQuery/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,15 @@ extension Client {
}

func unsubscribe(matching matcher: @escaping (SubscriptionRecord) -> Bool) {
subscriptions.filter {
matcher($0)
}.forEach {
_ = sendOperationAsync(.unsubscribe(requestId: $0.requestId))
var temp = [SubscriptionRecord]()
subscriptions.forEach {
if matcher($0) {
_ = sendOperationAsync(.unsubscribe(requestId: $0.requestId))
} else {
temp.append($0)
}
}
subscriptions = temp
}
}

Expand Down

0 comments on commit 8715b15

Please sign in to comment.