Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Dispose of subscriptions properly when deactivating
Browse files Browse the repository at this point in the history
  • Loading branch information
Wliu authored and Wliu committed Nov 4, 2017
1 parent 7c0a652 commit c353913
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
const {CompositeDisposable} = require('atom')

let TimecopView = null
const ViewURI = 'atom://timecop'

module.exports = {
activate () {
atom.workspace.addOpener(filePath => {
this.subscriptions = new CompositeDisposable()
this.subscriptions.add(atom.workspace.addOpener(filePath => {
if (filePath === ViewURI) return this.createTimecopView({uri: ViewURI})
})
}))

this.subscriptions.add(atom.commands.add('atom-workspace', 'timecop:view', () => atom.workspace.open(ViewURI)))
},

atom.commands.add('atom-workspace', 'timecop:view', () => atom.workspace.open(ViewURI))
deactivate () {
this.subscriptions.dispose()
},

createTimecopView (state) {
Expand Down

0 comments on commit c353913

Please sign in to comment.