Skip to content

Instantly share code, notes, and snippets.

@kim-codes
Created December 1, 2016 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kim-codes/9b1d797a28ff69e5e40406d5ae41a3da to your computer and use it in GitHub Desktop.
Save kim-codes/9b1d797a28ff69e5e40406d5ae41a3da to your computer and use it in GitHub Desktop.
'use babel';
import NewPackageView from './new-package-view';
import { CompositeDisposable } from 'atom';
export default {
newPackageView: null,
modalPanel: null,
subscriptions: null,
activate(state) {
this.newPackageView = new NewPackageView(state.newPackageViewState);
this.modalPanel = atom.workspace.addModalPanel({
item: this.newPackageView.getElement(),
visible: false
});
// Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
this.subscriptions = new CompositeDisposable();
// Register command that toggles this view
this.subscriptions.add(atom.commands.add('atom-workspace', {
'new-package:toggle': () => this.toggle()
}));
},
deactivate() {
this.modalPanel.destroy();
this.subscriptions.dispose();
this.newPackageView.destroy();
},
serialize() {
return {
newPackageViewState: this.newPackageView.serialize()
};
},
toggle() {
console.log('NewPackage was toggled!');
return (
this.modalPanel.isVisible() ?
this.modalPanel.hide() :
this.modalPanel.show()
);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment