Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 05cfbee

Browse files
committed
nits
1 parent ed4f859 commit 05cfbee

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Sources/ParseLiveQuery/Client.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ extension Client {
128128
_ query: PFQuery<T>,
129129
subclassType: T.Type = T.self
130130
) -> Subscription<T> where T: PFObject {
131-
return Subscription<T>()
132-
//return subscribe(query, handler: Subscription<T>())
131+
return subscribe(query, handler: Subscription<T>())
133132
}
134133

135134
/**
@@ -140,10 +139,10 @@ extension Client {
140139

141140
- returns: Your subscription handler, for easy chaining.
142141
*/
143-
public func subscribe<T: PFObject, U>(
142+
public func subscribe<T, U>(
144143
_ query: PFQuery<T>,
145144
handler: U
146-
) -> U where T: PFObject, U: SubscriptionHandling, U.PFGenericObject == T {
145+
) -> U where T: PFObject, U: SubscriptionHandling, U.PFObjectSubclass == T {
147146
let subscriptionRecord = SubscriptionRecord(
148147
query: query,
149148
requestId: requestIdGenerator(),
@@ -169,7 +168,8 @@ extension Client {
169168

170169
- parameter query: The query to unsubscribe from.
171170
*/
172-
public func unsubscribe<T>(_ query: PFQuery<T>) where T: PFObject {
171+
@objc(unsubscribeFromQuery:)
172+
public func unsubscribe(_ query: PFQuery<PFObject>) {
173173
unsubscribe { $0.query == query }
174174
}
175175

@@ -179,7 +179,7 @@ extension Client {
179179
- parameter query: The query to unsubscribe from.
180180
- parameter handler: The specific handler to unsubscribe from.
181181
*/
182-
public func unsubscribe<T, U>(_ query: PFQuery<U>, handler: T) where T: SubscriptionHandling, U: PFObject {
182+
public func unsubscribe<T, U>(_ query: PFQuery<T>, handler: U) where T: PFObject, U: SubscriptionHandling, U.PFObjectSubclass == T {
183183
unsubscribe { $0.query == query && $0.subscriptionHandler === handler }
184184
}
185185

Sources/ParseLiveQuery/Internal/ClientPrivate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ extension Client {
5858
let query: PFQuery<PFObject>
5959
let requestId: RequestId
6060

61-
init<T>(query: PFQuery<T.PFGenericObject>, requestId: RequestId, handler: T) where T:SubscriptionHandling {
61+
init<T>(query: PFQuery<T.PFObjectSubclass>, requestId: RequestId, handler: T) where T:SubscriptionHandling {
6262
self.query = query as! PFQuery<PFObject>
6363
self.requestId = requestId
6464

Sources/ParseLiveQuery/Subscription.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import BoltsSwift
1818
*/
1919
public protocol SubscriptionHandling: AnyObject {
2020
/// The type of the PFObject subclass that this handler uses.
21-
associatedtype PFGenericObject: PFObject
21+
associatedtype PFObjectSubclass: PFObject
2222

2323
/**
2424
Tells the handler that an event has been received from the live query server.
@@ -27,7 +27,7 @@ public protocol SubscriptionHandling: AnyObject {
2727
- parameter query: The query that the event occurred on.
2828
- parameter client: The live query client which received this event.
2929
*/
30-
func didReceive(_ event: Event<PFGenericObject>, forQuery query: PFQuery<PFGenericObject>, inClient client: Client)
30+
func didReceive(_ event: Event<PFObjectSubclass>, forQuery query: PFQuery<PFObjectSubclass>, inClient client: Client)
3131

3232
/**
3333
Tells the handler that an error has been received from the live query server.
@@ -36,7 +36,7 @@ public protocol SubscriptionHandling: AnyObject {
3636
- parameter query: The query that the error occurred on.
3737
- parameter client: The live query client which received this error.
3838
*/
39-
func didEncounter(_ error: Error, forQuery query: PFQuery<PFGenericObject>, inClient client: Client)
39+
func didEncounter(_ error: Error, forQuery query: PFQuery<PFObjectSubclass>, inClient client: Client)
4040

4141
/**
4242
Tells the handler that a query has been successfully registered with the server.
@@ -46,7 +46,7 @@ public protocol SubscriptionHandling: AnyObject {
4646
- parameter query: The query that has been subscribed.
4747
- parameter client: The live query client which subscribed this query.
4848
*/
49-
func didSubscribe(toQuery query: PFQuery<PFGenericObject>, inClient client: Client)
49+
func didSubscribe(toQuery query: PFQuery<PFObjectSubclass>, inClient client: Client)
5050

5151
/**
5252
Tells the handler that a query has been successfully deregistered from the server.
@@ -56,7 +56,7 @@ public protocol SubscriptionHandling: AnyObject {
5656
- parameter query: The query that has been unsubscribed.
5757
- parameter client: The live query client which unsubscribed this query.
5858
*/
59-
func didUnsubscribe(fromQuery query: PFQuery<PFGenericObject>, inClient client: Client)
59+
func didUnsubscribe(fromQuery query: PFQuery<PFObjectSubclass>, inClient client: Client)
6060
}
6161

6262
/**

0 commit comments

Comments
 (0)