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

Map subscription is not notified if initial value is added immediately after subscribing #42

Closed Legioth closed 3 years ago

Legioth commented 3 years ago

Describe the bug Map subscription is not notified if initial value is added immediately after subscribing.

To Reproduce

@Route("")
@Push
public class InitialSubscribe extends Div {
    public InitialSubscribe() {
        SystemUserInfo user = SystemUserInfo.getInstance();
        CollaborationEngine.getInstance().openTopicConnection(this, "topic", user, connection -> {
            CollaborationMap map = connection.getNamedMap("map");

            map.subscribe(changeEvent -> add(new Paragraph("Value: " + changeEvent.getValue(String.class))));

            map.put("key", "value");

            return null;
        });
    }
}

Steps to reproduce the behavior:

  1. Start the application and open the view
  2. Observe that no Value: value text is shown
  3. Open another tab, and observe that the text is shown in this case

Expected behavior Expected that the subscriber is always triggered when the value is changed. This is the case if the order is changed so that put is done before subscribe.

Versions

Legioth commented 3 years ago

Seems like this was already fixed for version 3.1. No idea why I was using such an old version...