Having another look at existing types: In browse-request we have:
* execute() * executeWithInterceptor() In discovery-request we have: * execute() * executeWithHandler() So, in order to continue that pattern, what do you think about having two options: * execute() * executeWithHandler() And to add the option to add a handler to the response. I know this could let users miss first responses, especially as ADS for example sends an event directly after subscribing. However it would be more in line with the rest of the API, which all have an “execute” without any arguments. Thinking even more about everything … I think moving the “executeWithInterceptor” .. the interceptor adding should actually more be added to the request and not the execution. Also could we add a “WithHandler” option to every type of request. Chris Von: Christofer Dutz <christofer.d...@c-ware.de> Datum: Montag, 25. März 2024 um 09:15 An: dev@plc4x.apache.org <dev@plc4x.apache.org> Betreff: [DISCUSS] Where to regster the handler? Hi all, so yesterday I‘ve been working on the refactoring of the subscriptions as we discussed that on the meetup. So, we said to register a callback for all fields before the “execute()” Consumer<PlcSubscriptionEvent> subscriptionConsumer = …; PlcSubscriptionRequest.Builder builder = plcConnection.subscriptionRequestBuilder(); for (int i = 0; i < options.getTagAddress().length; i++) { builder.addChangeOfStateTagAddress("value-" + i, options.getTagAddress()[i]); } PlcSubscriptionRequest subscriptionRequest = builder.build(subscriptionConsumer); // Execute the subscription response. final PlcSubscriptionResponse subscriptionResponse = subscriptionRequest.execute().get(); Right now, I initially thought about adding it to the build()-method, but that sort of felt oddly. Thinking about it a bit more, adding it to the “execute” seemed a bit more like what I was looking for. So, what do you think about doing: Consumer<PlcSubscriptionEvent> subscriptionConsumer = …; PlcSubscriptionRequest.Builder builder = plcConnection.subscriptionRequestBuilder(); for (int i = 0; i < options.getTagAddress().length; i++) { builder.addChangeOfStateTagAddress("value-" + i, options.getTagAddress()[i]); } PlcSubscriptionRequest subscriptionRequest = builder.build(); // Execute the subscription response. final PlcSubscriptionResponse subscriptionResponse = subscriptionRequest.execute(subscriptionConsumer).get(); What’s your opinion? I prefer the adding to the “execute” method. Chris