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

Release 2.7.0 Discussion #199

Closed
noobs2ninjas opened this issue Jul 27, 2019 · 4 comments
Closed

Release 2.7.0 Discussion #199

noobs2ninjas opened this issue Jul 27, 2019 · 4 comments

Comments

@noobs2ninjas
Copy link
Member

noobs2ninjas commented Jul 27, 2019

I opened a project to keep track of everything on Suggestion of @dplewis. I figured Id use this issue to kind of bring everyone up to speed and give a place to discuss updates. Needless to say PLQ could use some TLC. Heres a quick list of things I found in the last few days.

  • Handler and Event Handler functions do not get called.
  • Between Handler and Event handler there are A LOT of call back functions which can get confusing.
  • Documentation is lacking for ParseLiveQuery and the only example in the README doesn't work.
  • Jenkins and CircleCI isn't nearly as cut and dry as Parse-iOS-OSX-SDK which seems to make it a bit more difficult to maintain.
  • The project itself is bloated as our gitignore isn't ignoring all the Carthage files.

Ill add more as they come to me.

@noobs2ninjas
Copy link
Member Author

I'd like to consider the possibility of 2.7.0 being ParseLiveQuery's very last release. I've been talking to a few of the other Parse contributors like @TomWFox and we thought that ParseLiveQuery would be easier to maintain and keep a high overall code quality in general if it became an actual Parse module. So, I'd like to think about making 2.7.0 one heck of an update to bring it up to standard with the core parse repository. This means file structure, coding standards, naming conventions, and UnitTesting and travis/circleci integration. That way the transition is super smooth and easy and it fits right in.

@devwaseem
Copy link

devwaseem commented Aug 4, 2019

import Parse
import ParseLiveQuery


@objc protocol LiveQueryDelegate {
    @objc optional func didUpdate(UID:String,object:PFObject)
    @objc optional func didDelete(UID:String,object:PFObject)
    @objc optional func didEntered(UID:String,object:PFObject)
    @objc optional func didLeft(UID:String,object:PFObject)
    @objc optional func didEncounterError(UID:String,error:Error)
}
class LiveQuery {
    var UID:String
    var query:PFQuery<PFObject>
    var subscription:Subscription<PFObject>
    var subscriptionHandlers:[Subscription<PFObject>?] = []
    var subscriptionErrorHandler:Subscription<PFObject>?

    weak var delegate:LiveQueryDelegate? {
        didSet {
            //memory handling
            if delegate == nil {
                Client.shared.unsubscribe(query)
                self.subscriptionHandlers.removeAll()
            }
        }
    }
    
    init(UID:String,query:PFQuery<PFObject>){
        self.UID = UID
        self.query = query
        subscription = Client.shared.subscribe(self.query)
        subscriptionHandlers.append(
            subscription.handle(Event.created) { (_, object) in
                self.delegate?.didCreate?(UID: self.UID, object: object)
            }
        )
        subscriptionHandlers.append(
            subscription.handle(Event.deleted) { (_, object) in
                self.delegate?.didDelete?(UID: self.UID, object: object)
            }
        )
        subscriptionHandlers.append(
            subscription.handle(Event.updated) { (_, object) in
                self.delegate?.didUpdate?(UID: self.UID, object: object)
            }
        )
        subscriptionHandlers.append(
            subscription.handle(Event.left) { (_, object) in
                self.delegate?.didLeft?(UID: self.UID, object: object)
            }
        )
        
        subscriptionHandlers.append(
            subscription.handle(Event.entered) { (_, object) in
                self.delegate?.didEntered?(UID: self.UID, object: object)
            }
        )
        
        
        self.subscriptionErrorHandler = subscription.handleError({ (object, error) in
            self.delegate?.didEncounterError?(UID: self.UID, error: error)
        })
    }
    
    deinit {
        Client.shared.unsubscribe(query)
        self.subscriptionHandlers.removeAll()
    }
    
    
}

for those people who say Handlers are not working so, I made this class for temporary Fix. use this class and implement delegate methods in your view controller or ViewModel.

@noobs2ninjas
Copy link
Member Author

noobs2ninjas commented Aug 5, 2019

@devwaseem I think we actually have a fix for this which is found on #190 which will come out in the next day or two days along with dependency updates.

I will say I love the idea of the LiveQueryDelegate. I'd love to see 2.7.0 update the framework to use proper Apple protocol/delegate naming conventions vs the whatever named protocol we have now. I cant ever remember what its called which leaves me typing stuff till code completion suggests it.

@noobs2ninjas
Copy link
Member Author

I'm going to close this issue and open a new one for specifically iOS 13 and iPad OS since that update will cover everything we need for 2.7.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants