parse-community / ParseLiveQuery-iOS-OSX

Parse LiveQuery Client for iOS/OS X.
https://parseplatform.org
Other
192 stars 133 forks source link

Subscription handler failing on array of subscriptions #219

Closed brianmwadime closed 5 years ago

brianmwadime commented 5 years ago

Hello, I am try to create multiple subscriptions and adding them to an array, but the handlers don't seem to get fired when the objects and created/updated.

But it works fine with a single subscription. Is it not possible to have an array and have all the subscription handlers fire as well?

 threads?.forEach({[weak self] (thread) in
        guard let me = self else { return }
        let msgQuery = PFMessage.query()
        msgQuery?.whereKey("threadId", equalTo: thread.objectId)
        me.subscriptions?.append(subscription!)
        me.subscriptions?.last?.handle(Event.created) { _, message in
          if let messsage = Message(message: message) {
            if(messsage.senderId == userId) { return }
            messsage.post()
          }
        }
  })
brianmwadime commented 5 years ago

nvm, figured out a solution, everything works when I keep an array of the handlers.

noobs2ninjas commented 5 years ago

@brianmwadime what version are you running? It should not be dropping the handler references. The current version had a fix for this, or so we thought.

brianmwadime commented 5 years ago

@noobs2ninjas I did an update and they started working. The fix is solid.

noobs2ninjas commented 5 years ago

@brianmwadime Just wanted to make sure. Thanks for letting me know.