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