1

I have this code in Swift 3 to get backendless user so I can get his/her properties:

            let whereClause = "objectId = '\(userId)'"

            let query = BackendlessDataQuery()
            query.whereClause = whereClause

            let data = Backendless.sharedInstance().persistenceService.of(BackendlessUser.ofClass())

            data?.find(query, response: { (result) in

                let user = result?.data.first as! BackendlessUser

                myLabel.text = user.getProperty("firstName") as! String

          })

The code is working fine but my question is how to observe the property changes ? is there a way if the value of property firstName changed I can update my label automatically ?

Zizoo
  • 1,694
  • 5
  • 20
  • 42

1 Answers1

0

The use-case you describe is not really as simple as it may seem, but it's definitely possible.

You can capture any changes in Users table by creating an afterUpdate event handler. From there you could publish a message to some dedicated channel in messaging service.

At the same time, your application should be subscribed to this same channel. This way you could update your UI when the appropriate message is received.

Scadge
  • 9,380
  • 3
  • 30
  • 39