Helper for updating a UI based on events from a subscription
To properly update something in a Vaadin UI from asynchronous handlers from some kind of subscription, you need to take care of locking the UI, reacting to exception if the UI is detached and make sure you unsubscribe when the UI or view is detached. All this easily adds up to quite many rows of boilerplate.
Accessor is a helper that takes care of all those details for you as long as you provide a callback for updating the UI, a callback for actually subscribing to the updates and a component to bind the life cycle to.
Basic usage follows this form:
Accessor.ofConsumer(this::addMessage) .withSubscriber(DemoSubscription::subscribe) .bind(this);