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.
feat: Add the ability to access ParseConfig as a dictionary (#68)
* wip * feat: Add the ability to access ParseConfig as a dictionary * nits * nits
- Loading branch information
Showing
26 changed files
with
1,171 additions
and
265 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// ParseConfigCodable+async.swift | ||
// ParseSwift | ||
// | ||
// Created by Corey Baker on 3/10/23. | ||
// Copyright © 2023 Network Reconnaissance Lab. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension ParseConfigCodable { | ||
|
||
// MARK: Fetchable - Async/Await | ||
|
||
/** | ||
Fetch the Config *asynchronously*. | ||
- parameter options: A set of header options sent to the server. Defaults to an empty set. | ||
- returns: The return type of self. | ||
- throws: An error of type `ParseError`. | ||
- note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer | ||
desires a different policy, it should be inserted in `options`. | ||
*/ | ||
static func fetch(options: API.Options = []) async throws -> [String: V] { | ||
try await withCheckedThrowingContinuation { continuation in | ||
Self.fetch(options: options, | ||
completion: continuation.resume) | ||
} | ||
} | ||
|
||
// MARK: Savable - Async/Await | ||
|
||
/** | ||
Update the Config *asynchronously*. | ||
- parameter config: The Config to update on the server. | ||
- parameter options: A set of header options sent to the server. Defaults to an empty set. | ||
- returns: **true** if saved, **false** if save is unsuccessful. | ||
- throws: An error of type `ParseError`. | ||
*/ | ||
static func save(_ config: [String: V], | ||
options: API.Options = []) async throws -> Bool { | ||
try await withCheckedThrowingContinuation { continuation in | ||
Self.save(config, | ||
options: options, | ||
completion: continuation.resume) | ||
} | ||
} | ||
|
||
} |
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,48 @@ | ||
// | ||
// ParseConfigCodable+combine.swift | ||
// ParseSwift | ||
// | ||
// Created by Corey Baker on 3/10/23. | ||
// Copyright © 2023 Network Reconnaissance Lab. All rights reserved. | ||
// | ||
|
||
#if canImport(Combine) | ||
import Foundation | ||
import Combine | ||
|
||
public extension ParseConfigCodable { | ||
|
||
// MARK: Combine | ||
|
||
/** | ||
Fetch the Config *asynchronously*. Publishes when complete. | ||
- parameter options: A set of header options sent to the server. Defaults to an empty set. | ||
- returns: A publisher that eventually produces a single value and then finishes or fails. | ||
- note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer | ||
desires a different policy, it should be inserted in `options`. | ||
*/ | ||
static func fetchPublisher(options: API.Options = []) -> Future<[String: V], ParseError> { | ||
Future { promise in | ||
Self.fetch(options: options, | ||
completion: promise) | ||
} | ||
} | ||
|
||
/** | ||
Update the Config *asynchronously*. Publishes when complete. | ||
- parameter config: The Config to update on the server. | ||
- parameter options: A set of header options sent to the server. Defaults to an empty set. | ||
- returns: A publisher that eventually produces a single value and then finishes or fails. | ||
*/ | ||
static func savePublisher(_ config: [String: V], | ||
options: API.Options = []) -> Future<Bool, ParseError> { | ||
Future { promise in | ||
Self.save(config, | ||
options: options, | ||
completion: promise) | ||
} | ||
} | ||
|
||
} | ||
|
||
#endif |
Oops, something went wrong.