Skip to content

feat: add ParsePointer async fetch #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
branches: '*'
env:
CI_XCODE_VER: '/Applications/Xcode_11.7.app/Contents/Developer'
CI_XCODE_13: '/Applications/Xcode_13.0.app/Contents/Developer'
CI_XCODE_13: '/Applications/Xcode_13.1.app/Contents/Developer'

jobs:
xcode-test-ios:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Version
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}

xcode-test-macos:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Create and set the default keychain
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}

xcode-test-tvos:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Build
Expand All @@ -96,7 +96,7 @@ jobs:
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}

xcode-build-watchos:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Build
Expand All @@ -111,7 +111,7 @@ jobs:
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}

spm-test:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Create and set the default keychain
Expand Down Expand Up @@ -201,7 +201,7 @@ jobs:

docs:
needs: xcode-build-watchos
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Cache Gems
Expand All @@ -224,7 +224,7 @@ jobs:

cocoapods:
needs: xcode-build-watchos
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Update Framework Version
Expand All @@ -238,7 +238,7 @@ jobs:

carthage:
needs: xcode-build-watchos
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Carthage
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
types: [published]
env:
CI_XCODE_VER: '/Applications/Xcode_11.7.app/Contents/Developer'
CI_XCODE_13: '/Applications/Xcode_13.0.app/Contents/Developer'
CI_XCODE_13: '/Applications/Xcode_13.1.app/Contents/Developer'

jobs:
cocoapods:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Get release version
Expand All @@ -24,7 +24,7 @@ jobs:
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}

docs:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Cache Gems
Expand Down
28 changes: 28 additions & 0 deletions ParseSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,17 @@
70BDA2B4250536FF00FC2237 /* ParseInstallation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70BDA2B2250536FF00FC2237 /* ParseInstallation.swift */; };
70BDA2B5250536FF00FC2237 /* ParseInstallation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70BDA2B2250536FF00FC2237 /* ParseInstallation.swift */; };
70BDA2B6250536FF00FC2237 /* ParseInstallation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70BDA2B2250536FF00FC2237 /* ParseInstallation.swift */; };
70C167AF27304EE4009F4E30 /* Pointer+combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167AE27304EE4009F4E30 /* Pointer+combine.swift */; };
70C167B027304EE4009F4E30 /* Pointer+combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167AE27304EE4009F4E30 /* Pointer+combine.swift */; };
70C167B127304EE4009F4E30 /* Pointer+combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167AE27304EE4009F4E30 /* Pointer+combine.swift */; };
70C167B227304EE4009F4E30 /* Pointer+combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167AE27304EE4009F4E30 /* Pointer+combine.swift */; };
70C167B427304F09009F4E30 /* Pointer+async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167B327304F09009F4E30 /* Pointer+async.swift */; };
70C167B527304F09009F4E30 /* Pointer+async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167B327304F09009F4E30 /* Pointer+async.swift */; };
70C167B627304F09009F4E30 /* Pointer+async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167B327304F09009F4E30 /* Pointer+async.swift */; };
70C167B727304F09009F4E30 /* Pointer+async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167B327304F09009F4E30 /* Pointer+async.swift */; };
70C167B927305101009F4E30 /* ParsePointerAsyncTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167B827305101009F4E30 /* ParsePointerAsyncTests.swift */; };
70C167BA27305101009F4E30 /* ParsePointerAsyncTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167B827305101009F4E30 /* ParsePointerAsyncTests.swift */; };
70C167BB27305101009F4E30 /* ParsePointerAsyncTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C167B827305101009F4E30 /* ParsePointerAsyncTests.swift */; };
70C5502225B3D8F700B5DBC2 /* ParseAppleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C5502125B3D8F700B5DBC2 /* ParseAppleTests.swift */; };
70C5502325B3D8F700B5DBC2 /* ParseAppleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C5502125B3D8F700B5DBC2 /* ParseAppleTests.swift */; };
70C5502425B3D8F700B5DBC2 /* ParseAppleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C5502125B3D8F700B5DBC2 /* ParseAppleTests.swift */; };
Expand Down Expand Up @@ -883,6 +894,9 @@
70BC0B32251903D1001556DB /* ParseGeoPointTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseGeoPointTests.swift; sourceTree = "<group>"; };
70BC988F252A5B5C00FF3074 /* Objectable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Objectable.swift; sourceTree = "<group>"; };
70BDA2B2250536FF00FC2237 /* ParseInstallation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseInstallation.swift; sourceTree = "<group>"; };
70C167AE27304EE4009F4E30 /* Pointer+combine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Pointer+combine.swift"; sourceTree = "<group>"; };
70C167B327304F09009F4E30 /* Pointer+async.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Pointer+async.swift"; sourceTree = "<group>"; };
70C167B827305101009F4E30 /* ParsePointerAsyncTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParsePointerAsyncTests.swift; sourceTree = "<group>"; };
70C5502125B3D8F700B5DBC2 /* ParseAppleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseAppleTests.swift; sourceTree = "<group>"; };
70C5503725B406B800B5DBC2 /* ParseSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseSession.swift; sourceTree = "<group>"; };
70C5504525B40D5200B5DBC2 /* ParseSessionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseSessionTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1169,6 +1183,7 @@
917BA43D2703E84000F8D747 /* ParseOperationAsyncTests.swift */,
7044C1EB25C5CC930011F6E7 /* ParseOperationCombineTests.swift */,
70C5508425B4A68700B5DBC2 /* ParseOperationTests.swift */,
70C167B827305101009F4E30 /* ParsePointerAsyncTests.swift */,
70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */,
70CE1D882545BF730018D572 /* ParsePointerTests.swift */,
91285B2026991EE80051B544 /* ParsePolygonTests.swift */,
Expand Down Expand Up @@ -1520,6 +1535,8 @@
7004C21F25B63C7A005E0AD9 /* ParseRelation.swift */,
91679D63268E596300F71809 /* ParseVersion.swift */,
F97B45BE24D9C6F200F4A88B /* Pointer.swift */,
70C167B327304F09009F4E30 /* Pointer+async.swift */,
70C167AE27304EE4009F4E30 /* Pointer+combine.swift */,
F97B45BB24D9C6F200F4A88B /* Query.swift */,
7045769726BD917500F86F71 /* Query+async.swift */,
7044C1AC25C4FC080011F6E7 /* Query+combine.swift */,
Expand Down Expand Up @@ -2060,6 +2077,7 @@
F97B45F224D9C6F200F4A88B /* Pointer.swift in Sources */,
703B095826BF480D005A112F /* ParseFacebook+combine.swift in Sources */,
70510AAC259EE25E00FEA700 /* LiveQuerySocket.swift in Sources */,
70C167AF27304EE4009F4E30 /* Pointer+combine.swift in Sources */,
7044C19125C4F5B60011F6E7 /* ParseFile+combine.swift in Sources */,
70F79A192639CE6F00731C46 /* ParseHealth.swift in Sources */,
7044C19F25C4FA870011F6E7 /* ParseOperation+combine.swift in Sources */,
Expand All @@ -2073,6 +2091,7 @@
7028373926BD8C89007688C9 /* ParseUser+async.swift in Sources */,
705A9A2F25991C1400B3547F /* Fileable.swift in Sources */,
89899D342603CF36002E2043 /* ParseTwitter.swift in Sources */,
70C167B427304F09009F4E30 /* Pointer+async.swift in Sources */,
F97B464A24D9C78B00F4A88B /* Delete.swift in Sources */,
F97B460624D9C6F200F4A88B /* ParseUser.swift in Sources */,
700396F825A394AE0052CB31 /* ParseLiveQueryDelegate.swift in Sources */,
Expand Down Expand Up @@ -2153,6 +2172,7 @@
91679D6D268F261800F71809 /* ParseVersionTests.swift in Sources */,
917BA44E2703F2B400F8D747 /* ParseFacebookAsyncTests.swift in Sources */,
911DB13624C4FC100027F3C7 /* ParseObjectTests.swift in Sources */,
70C167B927305101009F4E30 /* ParsePointerAsyncTests.swift in Sources */,
70E09E1C262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */,
89899D592603CF3E002E2043 /* ParseTwitterTests.swift in Sources */,
70CE1D892545BF730018D572 /* ParsePointerTests.swift in Sources */,
Expand Down Expand Up @@ -2270,6 +2290,7 @@
F97B45F324D9C6F200F4A88B /* Pointer.swift in Sources */,
703B095926BF480D005A112F /* ParseFacebook+combine.swift in Sources */,
70510AAD259EE25E00FEA700 /* LiveQuerySocket.swift in Sources */,
70C167B027304EE4009F4E30 /* Pointer+combine.swift in Sources */,
7044C19225C4F5B60011F6E7 /* ParseFile+combine.swift in Sources */,
70F79A1A2639CE6F00731C46 /* ParseHealth.swift in Sources */,
7044C1A025C4FA870011F6E7 /* ParseOperation+combine.swift in Sources */,
Expand All @@ -2283,6 +2304,7 @@
7028373A26BD8C89007688C9 /* ParseUser+async.swift in Sources */,
705A9A3025991C1400B3547F /* Fileable.swift in Sources */,
89899D332603CF36002E2043 /* ParseTwitter.swift in Sources */,
70C167B527304F09009F4E30 /* Pointer+async.swift in Sources */,
F97B464B24D9C78B00F4A88B /* Delete.swift in Sources */,
F97B460724D9C6F200F4A88B /* ParseUser.swift in Sources */,
700396F925A394AE0052CB31 /* ParseLiveQueryDelegate.swift in Sources */,
Expand Down Expand Up @@ -2372,6 +2394,7 @@
91679D6F268F261A00F71809 /* ParseVersionTests.swift in Sources */,
917BA4502703F2B400F8D747 /* ParseFacebookAsyncTests.swift in Sources */,
709B98512556ECAA00507778 /* ParseEncoderExtraTests.swift in Sources */,
70C167BB27305101009F4E30 /* ParsePointerAsyncTests.swift in Sources */,
70E09E1E262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */,
89899D642603CF3F002E2043 /* ParseTwitterTests.swift in Sources */,
709B98532556ECAA00507778 /* ParsePointerTests.swift in Sources */,
Expand Down Expand Up @@ -2458,6 +2481,7 @@
91679D6E268F261900F71809 /* ParseVersionTests.swift in Sources */,
917BA44F2703F2B400F8D747 /* ParseFacebookAsyncTests.swift in Sources */,
70F2E2B6254F283000B2EA5C /* ParseACLTests.swift in Sources */,
70C167BA27305101009F4E30 /* ParsePointerAsyncTests.swift in Sources */,
70E09E1D262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */,
89899D632603CF3E002E2043 /* ParseTwitterTests.swift in Sources */,
70F2E2B7254F283000B2EA5C /* ParsePointerTests.swift in Sources */,
Expand Down Expand Up @@ -2575,6 +2599,7 @@
F97B45FD24D9C6F200F4A88B /* ParseACL.swift in Sources */,
703B095B26BF480D005A112F /* ParseFacebook+combine.swift in Sources */,
70510AAF259EE25E00FEA700 /* LiveQuerySocket.swift in Sources */,
70C167B227304EE4009F4E30 /* Pointer+combine.swift in Sources */,
7044C19425C4F5B60011F6E7 /* ParseFile+combine.swift in Sources */,
70F79A1C2639CE6F00731C46 /* ParseHealth.swift in Sources */,
7044C1A225C4FA870011F6E7 /* ParseOperation+combine.swift in Sources */,
Expand All @@ -2588,6 +2613,7 @@
7028373C26BD8C89007688C9 /* ParseUser+async.swift in Sources */,
705A9A3225991C1400B3547F /* Fileable.swift in Sources */,
89899D282603CF35002E2043 /* ParseTwitter.swift in Sources */,
70C167B727304F09009F4E30 /* Pointer+async.swift in Sources */,
F97B45F524D9C6F200F4A88B /* Pointer.swift in Sources */,
F97B460924D9C6F200F4A88B /* ParseUser.swift in Sources */,
700396FB25A394AE0052CB31 /* ParseLiveQueryDelegate.swift in Sources */,
Expand Down Expand Up @@ -2699,6 +2725,7 @@
F97B45FC24D9C6F200F4A88B /* ParseACL.swift in Sources */,
703B095A26BF480D005A112F /* ParseFacebook+combine.swift in Sources */,
70510AAE259EE25E00FEA700 /* LiveQuerySocket.swift in Sources */,
70C167B127304EE4009F4E30 /* Pointer+combine.swift in Sources */,
7044C19325C4F5B60011F6E7 /* ParseFile+combine.swift in Sources */,
70F79A1B2639CE6F00731C46 /* ParseHealth.swift in Sources */,
7044C1A125C4FA870011F6E7 /* ParseOperation+combine.swift in Sources */,
Expand All @@ -2712,6 +2739,7 @@
7028373B26BD8C89007688C9 /* ParseUser+async.swift in Sources */,
705A9A3125991C1400B3547F /* Fileable.swift in Sources */,
89899D322603CF35002E2043 /* ParseTwitter.swift in Sources */,
70C167B627304F09009F4E30 /* Pointer+async.swift in Sources */,
F97B45F424D9C6F200F4A88B /* Pointer.swift in Sources */,
F97B460824D9C6F200F4A88B /* ParseUser.swift in Sources */,
700396FA25A394AE0052CB31 /* ParseLiveQueryDelegate.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Objects/ParseObject+combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Combine

public extension ParseObject {

// MARK: Combine
// MARK: Fetchable - Combine
/**
Fetches the `ParseObject` *aynchronously* with the current data from the server and sets an error if one occurs.
Publishes when complete.
Expand Down
1 change: 1 addition & 0 deletions Sources/ParseSwift/Operations/ParseOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ public struct ParseOperation<T>: Savable where T: ParseObject {
}
}

// MARK: Savable
extension ParseOperation {
/**
Saves the operations on the `ParseObject` *synchronously* and throws an error if there's an issue.
Expand Down
8 changes: 5 additions & 3 deletions Sources/ParseSwift/Types/ParseFile+async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import FoundationNetworking
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
public extension ParseFile {

// MARK: Async/Await
// MARK: Fetchable - Async/Await
/**
Fetches a file with given url *synchronously*.
Fetches a file with given url *asynchronously*.
- 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.
- throws: `ParseError`.
Expand All @@ -30,7 +30,7 @@ public extension ParseFile {
}

/**
Fetches a file with given url *synchronously*.
Fetches a file with given url *asynchronously*.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- parameter progress: A block that will be called when file updates it's progress.
It should have the following argument signature: `(task: URLSessionDownloadTask,
Expand All @@ -48,6 +48,7 @@ public extension ParseFile {
}
}

// MARK: Savable - Async/Await
/**
Creates a file with given data *asynchronously* and executes the given callback block.
A name will be assigned to it by the server. If the file hasn't been downloaded, it will automatically
Expand Down Expand Up @@ -86,6 +87,7 @@ public extension ParseFile {
}
}

// MARK: Deletable - Async/Await
/**
Deletes the file from the Parse Server. Publishes when complete.
- requires: `.useMasterKey` has to be available.
Expand Down
4 changes: 3 additions & 1 deletion Sources/ParseSwift/Types/ParseFile+combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Combine

public extension ParseFile {

// MARK: Combine
// MARK: Fechable - Combine
/**
Fetches a file with given url *synchronously*. Publishes when complete.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
Expand Down Expand Up @@ -46,6 +46,7 @@ public extension ParseFile {
}
}

// MARK: Savable - Combine
/**
Creates a file with given data *asynchronously* and executes the given callback block.
Publishes when complete.
Expand Down Expand Up @@ -80,6 +81,7 @@ public extension ParseFile {
}
}

// MARK: Deletable - Combine
/**
Deletes the file from the Parse Server. Publishes when complete.
- requires: `.useMasterKey` has to be available.
Expand Down
33 changes: 33 additions & 0 deletions Sources/ParseSwift/Types/Pointer+async.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Pointer+async.swift
// ParseSwift
//
// Created by Corey Baker on 11/1/21.
// Copyright © 2021 Parse Community. All rights reserved.
//

#if swift(>=5.5) && canImport(_Concurrency)
import Foundation

// MARK: Fetchable - Async/Await
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
public extension Pointer {
/**
Fetches the `ParseObject` *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. 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: The `ParseObject` with respect to the `Pointer`.
*/
func fetch(includeKeys: [String]? = nil,
options: API.Options = []) async throws -> T {
try await withCheckedThrowingContinuation { continuation in
self.fetch(includeKeys: includeKeys,
options: options,
completion: continuation.resume)
}
}
}

#endif
33 changes: 33 additions & 0 deletions Sources/ParseSwift/Types/Pointer+combine.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Pointer+combine.swift
// ParseSwift
//
// Created by Corey Baker on 11/1/21.
// Copyright © 2021 Parse Community. All rights reserved.
//

#if canImport(Combine)
import Foundation
import Combine

// MARK: Fetchable - Combine
public extension Pointer {
/**
Fetches the `ParseObject` *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. 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 a single value and then finishes or fails.
*/
func fetchPublisher(includeKeys: [String]? = nil,
options: API.Options = []) -> Future<T, ParseError> {
Future { promise in
self.fetch(includeKeys: includeKeys,
options: options,
completion: promise)
}
}
}
#endif
Loading