Skip to content

Commit a5ba8cb

Browse files
authored
fix: completion block updates dispatch to callbackQueue (#19)
* fix: completion block updates dispatch to callbackQueue * nits * bump * further improvements
1 parent 9df3d2d commit a5ba8cb

28 files changed

+289
-219
lines changed

.swiftlint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
disabled_rules:
2+
- large_tuple
3+
- unused_optional_binding
4+
- type_name
25
- file_length
36
- cyclomatic_complexity
47
- function_body_length

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# Parse-Swift Changelog
22

33
### main
4-
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.16.1...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift)
4+
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.16.2...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift)
55
* _Contributing to this repo? Add info about your change here to be included in the next release_
66

7+
### 4.16.2
8+
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.16.1...4.16.2), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/4.16.2/documentation/parseswift)
9+
10+
__Fixes__
11+
- Callback async calls return to correct callbackQueue ([#19](https://github.com/netreconlab/Parse-Swift/pull/19)), thanks to [Corey Baker](https://github.com/cbaker6).
12+
713
### 4.16.1
814
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.16.0...4.16.1), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/4.16.1/documentation/parseswift)
915

1016
__Fixes__
11-
- Querying using findAll throws a hang risk warning in Xcode 14 ([#14](https://github.com/netreconlab/Parse-Swift/pull/10)), thanks to [Corey Baker](https://github.com/cbaker6).
17+
- Querying using findAll throws a hang risk warning in Xcode 14 ([#14](https://github.com/netreconlab/Parse-Swift/pull/14)), thanks to [Corey Baker](https://github.com/cbaker6).
1218

1319
### 4.16.0
1420
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.15.2...4.16.0), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/4.16.0/documentation/parseswift)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ For more information about the Parse Platform and its features, see the public [
2323
To learn how to use or experiment with ParseSwift, you can run and edit the [ParseSwift.playground](https://github.com/netreconlab/Parse-Swift/tree/main/ParseSwift.playground/Pages). You can use the parse-server in [this repo](https://github.com/netreconlab/parse-hipaa/tree/parse-swift) which has docker compose files (`docker-compose up` gives you a working server) configured to connect with the playground files, has [Parse Dashboard](https://github.com/parse-community/parse-dashboard), and can be used with MongoDB or PostgreSQL. You can also configure the Swift Playgrounds to work with your own Parse Server by editing the configuation in [Common.swift](https://github.com/netreconlab/Parse-Swift/blob/e9ba846c399257100b285d25d2bd055628b13b4b/ParseSwift.playground/Sources/Common.swift#L4-L19). To learn more, check out [CONTRIBUTING.md](https://github.com/netreconlab/Parse-Swift/blob/main/CONTRIBUTING.md#swift-playgrounds).
2424

2525
## Use Parse-Swift from NetReconLab
26-
This repo is maintained by [Corey E. Baker](https://github.com/cbaker6), [1 of 2 of the original developers of Parse-Swift](https://github.com/parse-community/Parse-Swift/graphs/contributors). Corey was responsible for the direction and development of all releases from [1.0.0](https://github.com/parse-community/Parse-Swift/releases/tag/4.14.2) to [4.14.2](https://github.com/parse-community/Parse-Swift/releases/tag/4.14.2). This repo will remain aligned with the original core principals of a swifty framework that contains zero dependencies and takes advantage of all of the features the [parse-server](https://github.com/parse-community/parse-server) has to offer. The reason for the bifurcation from the parse-community version of Parse-Swift is due to interference and a number of disagreements with a member of [Parse Project Management Committee (PMC)](https://github.com/parse-community/Governance/blob/main/TEAM.md#project-management-committee-pmc) about the future of ParseSwift along with the PMC member ignoring code reviews and comments, marking relevant comments as `off-topic`, merging commits directly to main branch, lack-of-understanding of Swift fundamentals, client-side development, and lack of knowledge about how the Parse-Swift framework is designed. It is important to emphasize that no member of the Parse PMC participated in the design, release, and direction of Parse-Swift from its [first commit](https://github.com/parse-community/Parse-Swift/tree/cf69b7f0638819a7070b82228bc51a97df5757e6) to version [4.14.2](https://github.com/parse-community/Parse-Swift/releases/tag/4.14.2). In addition, no funding or support from the [parse-community funds](https://opencollective.com/parse-server) was ever offered to Corey for any of his [contributions to Parse](https://github.com/search?q=user%3Aparse-community+author%3Acbaker6&type=issues), though a [number of payments have been offered and made to other contributors](https://opencollective.com/parse-server#category-BUDGET). If you benefit from Parse-Swift and would like to show monetary support, feel free to <a href="https://www.buymeacoffee.com/cbaker6" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
26+
This repo is maintained by [Corey E. Baker](https://github.com/cbaker6), [1 of 2 of the original developers of Parse-Swift](https://github.com/parse-community/Parse-Swift/graphs/contributors). Corey was responsible for the direction and development of all releases from [1.0.0](https://github.com/parse-community/Parse-Swift/releases/tag/4.14.2) to [4.14.2](https://github.com/parse-community/Parse-Swift/releases/tag/4.14.2). This repo will remain aligned with the original core principals of a swifty framework that contains zero dependencies and takes advantage of all of the features the [parse-server](https://github.com/parse-community/parse-server) has to offer. The reason for the bifurcation from the parse-community version of Parse-Swift is due to interference and a number of disagreements with the [Parse Project Management Committee (PMC)](https://github.com/parse-community/Governance/blob/main/TEAM.md#project-management-committee-pmc) about the future of ParseSwift along with the PMC member ignoring code reviews and comments, marking relevant comments as `off-topic`, merging commits directly to main branch, lack-of-understanding of Swift fundamentals, client-side development, and lack of knowledge about how the Parse-Swift framework is designed. It is important to emphasize that no member of the Parse PMC participated in the design, release, and direction of Parse-Swift from its [first commit](https://github.com/parse-community/Parse-Swift/tree/cf69b7f0638819a7070b82228bc51a97df5757e6) to version [4.14.2](https://github.com/parse-community/Parse-Swift/releases/tag/4.14.2). The Parse PMC also does not properly show attribution or appreciation to Corey as the lead developer of Parse-Swift. In addition, no funding or support from the [parse-community funds](https://opencollective.com/parse-server) has ever been offered to Corey for any of his [contributions to Parse](https://github.com/search?q=user%3Aparse-community+author%3Acbaker6&type=issues), though a [number of payments have been offered and made to other contributors](https://opencollective.com/parse-server#category-BUDGET). If you benefit from Parse-Swift and would like to show monetary support, feel free to <a href="https://www.buymeacoffee.com/cbaker6" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
2727

2828
---
2929

Sources/ParseSwift/API/API+Command+async.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ import FoundationNetworking
1414

1515
internal extension API.Command {
1616
// MARK: Asynchronous Execution
17-
func executeAsync(options: API.Options,
18-
batching: Bool = false,
19-
callbackQueue: DispatchQueue,
20-
notificationQueue: DispatchQueue? = nil,
21-
childObjects: [String: PointerType]? = nil,
22-
childFiles: [UUID: ParseFile]? = nil,
23-
uploadProgress: ((URLSessionTask, Int64, Int64, Int64) -> Void)? = nil,
24-
// swiftlint:disable:next line_length
25-
downloadProgress: ((URLSessionDownloadTask, Int64, Int64, Int64) -> Void)? = nil) async throws -> U {
17+
func execute(options: API.Options,
18+
batching: Bool = false,
19+
callbackQueue: DispatchQueue,
20+
notificationQueue: DispatchQueue? = nil,
21+
childObjects: [String: PointerType]? = nil,
22+
childFiles: [UUID: ParseFile]? = nil,
23+
uploadProgress: ((URLSessionTask, Int64, Int64, Int64) -> Void)? = nil,
24+
downloadProgress: ((URLSessionDownloadTask, Int64, Int64, Int64) -> Void)? = nil) async throws -> U {
2625
try await withCheckedThrowingContinuation { continuation in
2726
self.executeAsync(options: options,
2827
batching: batching,

Sources/ParseSwift/API/API+NonParseBodyCommand+async.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import FoundationNetworking
1414

1515
extension API.NonParseBodyCommand {
1616
// MARK: Asynchronous Execution
17-
func executeAsync(options: API.Options,
18-
callbackQueue: DispatchQueue) async throws -> U {
17+
func execute(options: API.Options,
18+
callbackQueue: DispatchQueue) async throws -> U {
1919
try await withCheckedThrowingContinuation { continuation in
2020
self.executeAsync(options: options,
2121
callbackQueue: callbackQueue,

Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,8 @@ public extension ParseUser {
286286
do {
287287
try signupCommand(body: body)
288288
.executeAsync(options: options,
289-
callbackQueue: callbackQueue) { result in
290-
completion(result)
291-
}
289+
callbackQueue: callbackQueue,
290+
completion: completion)
292291
} catch {
293292
let defaultError = ParseError(code: .unknownError,
294293
message: error.localizedDescription)
@@ -360,9 +359,8 @@ public extension ParseUser {
360359
let body = SignupLoginBody(authData: authData)
361360
current.linkCommand(body: body)
362361
.executeAsync(options: options,
363-
callbackQueue: callbackQueue) { result in
364-
completion(result)
365-
}
362+
callbackQueue: callbackQueue,
363+
completion: completion)
366364
} else {
367365
callbackQueue.async {
368366
completion(.success(self))
@@ -430,9 +428,8 @@ public extension ParseUser {
430428
let body = SignupLoginBody(authData: [type: authData])
431429
current.linkCommand(body: body)
432430
.executeAsync(options: options,
433-
callbackQueue: callbackQueue) { result in
434-
completion(result)
435-
}
431+
callbackQueue: callbackQueue,
432+
completion: completion)
436433
}
437434

438435
internal func linkCommand() throws -> API.Command<Self, Self> {

Sources/ParseSwift/Objects/ParseInstallation+async.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ internal extension ParseInstallation {
349349
command = try self.updateCommand()
350350
}
351351
let saved = try await command
352-
.executeAsync(options: options,
352+
.execute(options: options,
353353
callbackQueue: callbackQueue,
354354
childObjects: savedChildObjects,
355355
childFiles: savedChildFiles)
@@ -423,7 +423,7 @@ internal extension Sequence where Element: ParseInstallation {
423423
for batch in batches {
424424
let saved = try await API.Command<Self.Element, Self.Element>
425425
.batch(commands: batch, transaction: transaction)
426-
.executeAsync(options: options,
426+
.execute(options: options,
427427
batching: true,
428428
callbackQueue: callbackQueue,
429429
childObjects: childObjects,

Sources/ParseSwift/Objects/ParseInstallation.swift

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,7 @@ extension ParseInstallation {
555555
let defaultError = ParseError(code: .unknownError,
556556
message: error.localizedDescription)
557557
let parseError = error as? ParseError ?? defaultError
558-
callbackQueue.async {
559-
completion(.failure(parseError))
560-
}
558+
completion(.failure(parseError))
561559
}
562560
} else {
563561
completion(result)
@@ -700,7 +698,9 @@ extension ParseInstallation {
700698
ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig,
701699
options: options,
702700
callbackQueue: callbackQueue)
703-
completion(.success(object))
701+
callbackQueue.async {
702+
completion(.success(object))
703+
}
704704
} catch {
705705
let defaultError = ParseError(code: .unknownError,
706706
message: error.localizedDescription)
@@ -741,7 +741,9 @@ extension ParseInstallation {
741741
let object = try await command(method: method,
742742
options: options,
743743
callbackQueue: callbackQueue)
744-
completion(.success(object))
744+
callbackQueue.async {
745+
completion(.success(object))
746+
}
745747
} catch {
746748
let defaultError = ParseError(code: .unknownError,
747749
message: error.localizedDescription)
@@ -782,7 +784,9 @@ extension ParseInstallation {
782784
let object = try await command(method: method,
783785
options: options,
784786
callbackQueue: callbackQueue)
785-
completion(.success(object))
787+
callbackQueue.async {
788+
completion(.success(object))
789+
}
786790
} catch {
787791
let defaultError = ParseError(code: .unknownError,
788792
message: error.localizedDescription)
@@ -823,7 +827,9 @@ extension ParseInstallation {
823827
let object = try await command(method: method,
824828
options: options,
825829
callbackQueue: callbackQueue)
826-
completion(.success(object))
830+
callbackQueue.async {
831+
completion(.success(object))
832+
}
827833
} catch {
828834
let defaultError = ParseError(code: .unknownError,
829835
message: error.localizedDescription)
@@ -1017,9 +1023,7 @@ extension ParseInstallation {
10171023
let defaultError = ParseError(code: .unknownError,
10181024
message: error.localizedDescription)
10191025
let parseError = error as? ParseError ?? defaultError
1020-
callbackQueue.async {
1021-
completion(.failure(parseError))
1022-
}
1026+
completion(.failure(parseError))
10231027
}
10241028
case .failure(let error):
10251029
completion(.failure(error))
@@ -1207,7 +1211,9 @@ public extension Sequence where Element: ParseInstallation {
12071211
ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig,
12081212
options: options,
12091213
callbackQueue: callbackQueue)
1210-
completion(.success(objects))
1214+
callbackQueue.async {
1215+
completion(.success(objects))
1216+
}
12111217
} catch {
12121218
let defaultError = ParseError(code: .unknownError,
12131219
message: error.localizedDescription)
@@ -1261,7 +1267,9 @@ public extension Sequence where Element: ParseInstallation {
12611267
transaction: transaction,
12621268
options: options,
12631269
callbackQueue: callbackQueue)
1264-
completion(.success(objects))
1270+
callbackQueue.async {
1271+
completion(.success(objects))
1272+
}
12651273
} catch {
12661274
let defaultError = ParseError(code: .unknownError,
12671275
message: error.localizedDescription)
@@ -1315,7 +1323,9 @@ public extension Sequence where Element: ParseInstallation {
13151323
transaction: transaction,
13161324
options: options,
13171325
callbackQueue: callbackQueue)
1318-
completion(.success(objects))
1326+
callbackQueue.async {
1327+
completion(.success(objects))
1328+
}
13191329
} catch {
13201330
let defaultError = ParseError(code: .unknownError,
13211331
message: error.localizedDescription)
@@ -1369,7 +1379,9 @@ public extension Sequence where Element: ParseInstallation {
13691379
transaction: transaction,
13701380
options: options,
13711381
callbackQueue: callbackQueue)
1372-
completion(.success(objects))
1382+
callbackQueue.async {
1383+
completion(.success(objects))
1384+
}
13731385
} catch {
13741386
let defaultError = ParseError(code: .unknownError,
13751387
message: error.localizedDescription)

0 commit comments

Comments
 (0)