I have a simple panel that displays a button. In my main file I subscribe to events like so:
@subscriptions = new CompositeDisposable @subscriptions.add atom.workspace.observeTextEditors (editor) => buffer = editor.getBuffer() buffer.stoppedChangingDelay = 5000 bufferChangedSubscription = buffer.onDidStopChanging => buffer.transact => @someMethod()
I would like to dispose of these subscriptions and stop listening for
buffer.onDidStopChanging. Furthermore I would like to detect if theses subscriptions already exist in case I run the same command twice by accident. Every time I call the same command and check if
@subscriptions? exists I get undefined even though the events are still listening. In other words, @someMethod() gets called twice in a row if I subscribe twice. How can I detect if there exists subscriptions already? And how can I have a handle on the subscription linked to a button that disposes of them?