@@ -27,7 +27,7 @@ public protocol ObjCCompat_SubscriptionHandling {
2727 - parameter client: The live query client which received this event.
2828 */
2929 @objc ( liveQuery: didRecieveEvent: inClient: )
30- optional func didRecieveEvent( _ query: PFQuery < PFObject > , event: ObjCCompat . Event , client: Client )
30+ optional func didRecieveEvent( _ query: PFQuery < PFObject > , event: PFLiveQueryEvent , client: Client )
3131
3232 /**
3333 Tells the handler that an error has been received from the live query server.
@@ -62,9 +62,9 @@ public protocol ObjCCompat_SubscriptionHandling {
6262 optional func didUnsubscribe( _ query: PFQuery < PFObject > , client: Client )
6363}
6464
65- // HACK: Compiler bug causes enums that are declared in structs that are marked as @objc to not actually be emitted by
66- // the compiler (lolwut?). Moving this to global scope fixes the problem, but we can't change the objc name of an enum
67- // either, so we pollute the swift namespace here.
65+ // HACK: Compiler bug causes enums (and sometimes classes) that are declared in structs that are marked as @objc
66+ // to not actually be emitted by the compiler (lolwut?). Moving this to global scope fixes the problem, but we can't
67+ // change the objc name of an enum either, so we pollute the swift namespace here.
6868// TODO: Fix this eventually.
6969
7070/**
@@ -84,39 +84,39 @@ public enum PFLiveQueryEventType: Int {
8484 case deleted
8585}
8686
87+ /**
88+ Represents an update on a specific object from the live query server.
89+ */
90+ @objc
91+ open class PFLiveQueryEvent : NSObject {
92+ /// Type of the event.
93+ @objc
94+ public let type : PFLiveQueryEventType
95+
96+ /// Object this event is for.
97+ @objc
98+ public let object : PFObject
99+
100+ init ( type: PFLiveQueryEventType , object: PFObject ) {
101+ self . type = type
102+ self . object = object
103+ }
104+ }
105+
87106/**
88107 This struct wraps up all of our Objective-C compatibility layer. You should never need to touch this if you're using Swift.
89108 */
90109public struct ObjCCompat {
91110 fileprivate init ( ) { }
92111
93- /**
94- Represents an update on a specific object from the live query server.
95- */
96- @objc ( PFLiveQueryEvent)
97- open class Event : NSObject {
98- /// Type of the event.
99- @objc
100- public let type : PFLiveQueryEventType
101-
102- /// Object this event is for.
103- @objc
104- public let object : PFObject
105-
106- init ( type: PFLiveQueryEventType , object: PFObject ) {
107- self . type = type
108- self . object = object
109- }
110- }
111-
112112 /**
113113 A default implementation of the SubscriptionHandling protocol, using blocks for callbacks.
114114 */
115115 @objc ( PFLiveQuerySubscription)
116116 open class Subscription : NSObject {
117117 public typealias SubscribeHandler = @convention ( block) ( PFQuery < PFObject > ) -> Void
118118 public typealias ErrorHandler = @convention ( block) ( PFQuery < PFObject > , NSError ) -> Void
119- public typealias EventHandler = @convention ( block) ( PFQuery < PFObject > , Event ) -> Void
119+ public typealias EventHandler = @convention ( block) ( PFQuery < PFObject > , PFLiveQueryEvent ) -> Void
120120 public typealias ObjectHandler = @convention ( block) ( PFQuery < PFObject > , PFObject ) -> Void
121121
122122 var subscribeHandlers = [ SubscribeHandler] ( )
@@ -184,7 +184,7 @@ public struct ObjCCompat {
184184 - returns: The same subscription, for easy chaining.
185185 */
186186 @objc ( addEnterHandler: )
187- open func addEnterHandler( _ handler: @escaping ObjectHandler ) -> Subscription {
187+ open func addEnterHandler( _ handler: @escaping ObjectHandler ) -> Subscription {
188188 return addEventHandler { $1. type == . entered ? handler ( $0, $1. object) : ( ) }
189189 }
190190
@@ -239,7 +239,7 @@ public struct ObjCCompat {
239239}
240240
241241extension ObjCCompat . Subscription : ObjCCompat_SubscriptionHandling {
242- public func didRecieveEvent( _ query: PFQuery < PFObject > , event: ObjCCompat . Event , client: Client ) {
242+ public func didRecieveEvent( _ query: PFQuery < PFObject > , event: PFLiveQueryEvent , client: Client ) {
243243 eventHandlers. forEach { $0 ( query, event) }
244244 }
245245
@@ -270,7 +270,7 @@ extension Client {
270270 }
271271
272272 fileprivate func didReceive( _ event: Event < T > , forQuery query: PFQuery < T > , inClient client: Client ) {
273- handler? . didRecieveEvent ? ( query, event: ObjCCompat . Event ( event: event) , client: client)
273+ handler? . didRecieveEvent ? ( query, event: PFLiveQueryEvent ( event: event) , client: client)
274274 }
275275
276276 fileprivate func didEncounter( _ error: Error , forQuery query: PFQuery < T > , inClient client: Client ) {
@@ -338,7 +338,7 @@ extension Client {
338338// HACK: Another compiler bug - if you have a required initializer with a generic type, the compiler simply refuses to
339339// emit the entire class altogether. Moving this to an extension for now solves the issue.
340340
341- extension ObjCCompat . Event {
341+ extension PFLiveQueryEvent {
342342 convenience init < T> ( event: ParseLiveQuery . Event < T > ) {
343343 let results : ( type: PFLiveQueryEventType , object: PFObject ) = {
344344 switch event {
0 commit comments