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.
 

 

2 comments

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

0

Thank you Roman, it works!

0

Please sign in to leave a comment.