UI Shared state was accessed from a background thread

I want to use notifications in search Executor to show messages. How do I do that?

Hi,

  1. Obtain the current ui:
AppUI current = AppUI.getCurrent();
  1. Use the accessmethod:
current.access(() -> {
    notifications.create()
            .withCaption("Search String: " + searchString)
            .show();
});

Note: the current UI must be obtained outside of SearchExecutor scope, e.g.:

AppUI current = AppUI.getCurrent();
suggestionPickerField.setSearchExecutor((searchString, searchParams) -> {
    current.access(() -> {
        notifications.create()
                .withCaption("Search String: " + searchString)
                .show();
    });

    return ...;
});

Gleb

1 Like