vaadin / collaboration-engine

The simplest way to build real-time collaboration into web apps
https://vaadin.com/collaboration
Other
3 stars 1 forks source link

ExpirationTimeout on CollaborationBinder should lead to initialBeanSupplier call #40

Closed chrosim closed 3 years ago

chrosim commented 3 years ago

When using setExpirationTimeout on CollaborationBinder the CollaborationBinderMap is cleared in the Topic after reentering. This leads to an empty state on all fields bound to the CollaborationBinder.

I expect the CollaborationBinder to call the initialBeanSupplier when reentering a topic(which will have a cleared state) to show the actual persisted object and not an empty form.

Versions

pekam commented 3 years ago

Hi @chrosim, thanks for reporting! I couldn't reproduce the issue though.

Here's the relevant part of my code:

binder = new CollaborationBinder<>(Person.class, user);
binder.setExpirationTimeout(Duration.ZERO);
binder.setTopic(TOPIC_ID, () -> {
    Person p = new Person();
    p.setFirstName("default first name");
    p.setLastName("default last name");
    return p;
});

After closing the view and coming back, my callback runs and the returned value is used to populate my first name and last name fields.

Can you provide any more information that could help us recognize what's different in your case? A code snippet that we can use to reproduce the issue would be perfect!


Technically, the logic should go like this:

  1. Topic connection activates when binder has a topic and the related fields become attached to a UI.
  2. As the topic activates, if expirationTimeout has passed since the last time the same topic had an active connection, clear the CollaborationMap that holds the field values of CollaborationBinder.
  3. The topic activation callback of CollaborationBinder starts running.
  4. If the CollaborationMap doesn't hold any data related to the fields, load the values from the initial bean supplier.
Legioth commented 3 years ago

I'm closing this issue since we haven't heard about how to reproduce it. Please leave a comment here or open a new issue in case there's still something we could look into.