Coroutine friendly version of AnAction

Hi all,
will be possible to have a coroutine friendly version of AnAction?

The idea is to have at least update and actionPerformed as suspend function, with split mode could be that the update or actionPerformed rely on information that are on remote side and having it natively suspend function will help a lot.

Thanks a lot in advance.

Regards,
Mirko

Hi, please use the following pattern to launch suspend activities from actionPerformed:

class DemoAction: AnAction() {
  override fun actionPerformed(e: AnActionEvent) {
    e.coroutineScope.launch { 
      
    }

Not possible for update yet, unfortunately. There you had better create cache of data for actions and populate it asynchronously.

Just in case, which are the advantages of using this pattern?

It is a suspend activity originated from action, no need to create an additional service, coroutineScope it attached to project and plugin lifecycle, so cancellation works properly in case of dispose/close of project