How to unsubscribe a BulkFileListener

I registered one like this:

ApplicationManager.getApplication().getMessageBus().connect(project).subscribe(VFS_CHANGES, new ConfigBulkFileListener());

ConfigBulkFileListener is my implementation of BulkFileListener.

But how can I unsubscribe the listener? I tried:


ApplicationManager.getApplication().getMessageBus().connect(project).disconnect();
ApplicationManager.getApplication().getMessageBus().connect(project).subscribe(VFS_CHANGES, null);


both don't work, my listener still get triggered.

Thanks.
 

 

0

Keep the instance of `MessageBusConnection` returned by `connect()`, and call `disconnect()` on it.

1
Avatar
Permanently deleted user

Thank you Roman, it works!

1

请先登录再写评论。