Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### main

__Improvements__
- Added @discardableResult to allow developers to choose whether or not certain functions should return a result ([#385](https://github.com/parse-community/Parse-Swift/pull/385)), thanks to [Damian Van de Kauter](https://github.com/vdkdamian).

[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.8.0...main)
* _Contributing to this repo? Add info about your change here to be included in the next release_

Expand Down
44 changes: 22 additions & 22 deletions Sources/ParseSwift/Objects/ParseObject+async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public extension ParseObject {
- note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer
desires a different policy, it should be inserted in `options`.
*/
func fetch(includeKeys: [String]? = nil,
options: API.Options = []) async throws -> Self {
@discardableResult func fetch(includeKeys: [String]? = nil,
options: API.Options = []) async throws -> Self {
try await withCheckedThrowingContinuation { continuation in
self.fetch(includeKeys: includeKeys,
options: options,
Expand All @@ -41,8 +41,8 @@ public extension ParseObject {
- returns: Returns the saved `ParseObject`.
- throws: An error of type `ParseError`.
*/
func save(ignoringCustomObjectIdConfig: Bool = false,
options: API.Options = []) async throws -> Self {
@discardableResult func save(ignoringCustomObjectIdConfig: Bool = false,
options: API.Options = []) async throws -> Self {
try await withCheckedThrowingContinuation { continuation in
self.save(ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig,
options: options,
Expand All @@ -56,7 +56,7 @@ public extension ParseObject {
- returns: Returns the saved `ParseObject`.
- throws: An error of type `ParseError`.
*/
func create(options: API.Options = []) async throws -> Self {
@discardableResult func create(options: API.Options = []) async throws -> Self {
try await withCheckedThrowingContinuation { continuation in
self.create(options: options,
completion: continuation.resume)
Expand All @@ -69,7 +69,7 @@ public extension ParseObject {
- returns: Returns the saved `ParseObject`.
- throws: An error of type `ParseError`.
*/
func replace(options: API.Options = []) async throws -> Self {
@discardableResult func replace(options: API.Options = []) async throws -> Self {
try await withCheckedThrowingContinuation { continuation in
self.replace(options: options,
completion: continuation.resume)
Expand All @@ -82,7 +82,7 @@ public extension ParseObject {
- returns: Returns the saved `ParseObject`.
- throws: An error of type `ParseError`.
*/
internal func update(options: API.Options = []) async throws -> Self {
@discardableResult internal func update(options: API.Options = []) async throws -> Self {
try await withCheckedThrowingContinuation { continuation in
self.update(options: options,
completion: continuation.resume)
Expand Down Expand Up @@ -118,8 +118,8 @@ public extension Sequence where Element: ParseObject {
`ParseError` if it failed.
- throws: An error of type `ParseError`.
*/
func fetchAll(includeKeys: [String]? = nil,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
@discardableResult func fetchAll(includeKeys: [String]? = nil,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
self.fetchAll(includeKeys: includeKeys,
options: options,
Expand Down Expand Up @@ -156,10 +156,10 @@ public extension Sequence where Element: ParseObject {
- note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer
desires a different policy, it should be inserted in `options`.
*/
func saveAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
ignoringCustomObjectIdConfig: Bool = false,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
@discardableResult func saveAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
ignoringCustomObjectIdConfig: Bool = false,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
self.saveAll(batchLimit: limit,
transaction: transaction,
Expand All @@ -186,9 +186,9 @@ public extension Sequence where Element: ParseObject {
- note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer
desires a different policy, it should be inserted in `options`.
*/
func createAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
@discardableResult func createAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
self.createAll(batchLimit: limit,
transaction: transaction,
Expand All @@ -214,9 +214,9 @@ public extension Sequence where Element: ParseObject {
- note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer
desires a different policy, it should be inserted in `options`.
*/
func replaceAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
@discardableResult func replaceAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
self.replaceAll(batchLimit: limit,
transaction: transaction,
Expand Down Expand Up @@ -267,9 +267,9 @@ public extension Sequence where Element: ParseObject {
objects in the transaction. The developer should ensure their respective Parse Servers can handle the limit or else
the transactions can fail.
*/
func deleteAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Void, ParseError>)] {
@discardableResult func deleteAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Void, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
self.deleteAll(batchLimit: limit,
transaction: transaction,
Expand Down