forked from parse-community/Parse-Swift
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
126 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// ParsePointerable+async.swift | ||
// ParseSwift | ||
// | ||
// Created by Corey Baker on 1/8/24. | ||
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
// swiftlint:disable line_length | ||
|
||
// MARK: Batch Support | ||
public extension Sequence where Element: ParsePointerObject { | ||
|
||
/** | ||
Fetches a collection of objects *aynchronously* with the current data from the server and sets | ||
an error if one occurs. | ||
- parameter includeKeys: The name(s) of the key(s) to include that are | ||
`ParseObject`s. Use `["*"]` to include all keys one level deep. This is similar to `include` and | ||
`includeAll` for `Query`. | ||
- parameter options: A set of header options sent to the server. Defaults to an empty set. | ||
- returns: Returns an array of Result enums with the object if a fetch was successful or a | ||
`ParseError` if it failed. | ||
- throws: An error of type `ParseError`. | ||
*/ | ||
@discardableResult func fetchAll(includeKeys: [String]? = nil, | ||
options: API.Options = []) async throws -> [(Result<Self.Element.Object, ParseError>)] { | ||
try await withCheckedThrowingContinuation { continuation in | ||
self.fetchAll(includeKeys: includeKeys, | ||
options: options, | ||
completion: continuation.resume) | ||
} | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
Sources/ParseSwift/Protocols/ParsePointerable+combine.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// ParsePointerable+combine.swift | ||
// ParseSwift | ||
// | ||
// Created by Corey Baker on 1/8/24. | ||
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved. | ||
// | ||
|
||
#if canImport(Combine) | ||
|
||
import Foundation | ||
import Combine | ||
|
||
// swiftlint:disable line_length | ||
|
||
// MARK: Batch Support | ||
public extension Sequence where Element: ParsePointerObject { | ||
|
||
/** | ||
Fetches a collection of objects *aynchronously* with the current data from the server and sets | ||
an error if one occurs. Publishes when complete. | ||
- parameter includeKeys: The name(s) of the key(s) to include that are | ||
`ParseObject`s. Use `["*"]` to include all keys one level deep. This is similar to `include` and | ||
`includeAll` for `Query`. | ||
- parameter options: A set of header options sent to the server. Defaults to an empty set. | ||
- returns: A publisher that eventually produces an an array of Result enums with the object if a fetch was | ||
successful or a `ParseError` if it failed. | ||
*/ | ||
func fetchAllPublisher(includeKeys: [String]? = nil, | ||
options: API.Options = []) -> Future<[(Result<Self.Element.Object, ParseError>)], ParseError> { | ||
Future { promise in | ||
self.fetchAll(includeKeys: includeKeys, | ||
options: options, | ||
completion: promise) | ||
} | ||
} | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters