Does relation change listener work now?

Hi Backendless team, I’m using BackendlessSwift 6.0.1.1. I noticed that in a recent update, some relation change listeners are added in the EventHandlerForClass file, such as addAddRelationListener and addSetRelationListener. I was just wondering do they work now? I tried using this API and seems not working on my side. Besides, the document didn’t seem to cover this update.

Backendless Version (3.x / 6.x, Online / Managed / Pro )

6.0.1.1

Client SDK (REST / Android / Objective-C / Swift / JS )

Swift

Application ID

3B8C2D2E-B7D6-27F9-FF3F-ABEE20934E00

Hi @Evan_Cui!

Could you provide code example of your listener which didn’t work?
In which way have you added new relations - using Console GUI or via REST API?

Regards, Andriy

Hello @Evan_Cui,

The listeners for relations are not released officially yet.
However, I’ve checked and this code works fine and listener triggers:

let _ = Backendless.shared.data.ofTable("Person").rt.addAddRelationListener(relationColumnName: "address", responseHandler: { status in
    print("Listener triggered!")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

Backendless.shared.data.ofTable("Person").addRelation(columnName: "address", parentObjectId: "F39C5358-E5E1-46AF-AD6F-5CA4BC9CA21E", childrenObjectIds: ["C17CF32D-02AD-43C4-8EB7-6CCB1A5E3BD1"], responseHandler: { relationsAdded in
    print("Relation added")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

Regards,
Olha

Hi @olhadanylova, thank you for your quick response. I tested your code, it worked.

However, I use a different way to add relation. I use transaction UnitOfWork to add the relation. In my case, the listener won’t be triggered. My code looks like

        let uow = UnitOfWork()
        let _ = uow.addToRelation(parentTableName: "Person", parentObjectId: "F39C5358-E5E1-46AF-AD6F-5CA4BC9CA21E", columnName: "address", childrenObjectIds: ["C17CF32D-02AD-43C4-8EB7-6CCB1A5E3BD1"])
        uow.execute(responseHandler: { result in
            print(result.isSuccess)
        }, errorHandler: { fault in
           print("Error: \(fault.message ?? "")")
        })

In my project, the addRelation work should be done in a transaction with some other operations. Does your team plan to add this listener support for transactions in the future?

Thanks again. Looking forward to your reply.

Hello @Evan_Cui

Yes, the change you requested is already added to the road-map.
Internal ticket BKNDLSS-22469.
We will let you know in topic when the changes are in.

Hi @Volodymyr_Ialovyi , Thanks for your confirmation. I’m very much looking forward to the new features.

1 Like

Hello @Evan_Cui

We have implemented this functionality. Please tell me if everything works as you expect?

Regards,
Inna