1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-17 20:11:12 +02:00

Add some more commands to commands palette.

Some refactoring also. Move palette events to commands.js.
This commit is contained in:
Kushagra Gour
2018-10-27 20:24:34 +05:30
parent 021f1390ab
commit f4de6572c2
6 changed files with 60 additions and 39 deletions

View File

@@ -1,18 +1,9 @@
import { deferred } from './deferred';
import { log } from 'util';
export const SWITCH_FILE_EVENT = 'switchFileEvent';
export const OPEN_SAVED_CREATIONS_EVENT = 'openSavedCreationsEvent';
export const SAVE_EVENT = 'saveEvent';
export const commandPaletteService = {
subscriptions: {},
subscribe(eventName, callback) {
console.log('subscribed for ', eventName);
this.subscriptions[eventName] = this.subscriptions[eventName] || [];
this.subscriptions[eventName].push(callback);
return () => {
console.log('Unsubscribing ', eventName);
this.subscriptions[eventName].splice(
this.subscriptions[eventName].indexOf(callback),
1
@@ -20,7 +11,6 @@ export const commandPaletteService = {
};
},
publish(eventName, ...args) {
console.log('published ', eventName, args);
const callbacks = this.subscriptions[eventName] || [];
callbacks.forEach(callback => {
callback.apply(null, args);