Skip to content

Commit

Permalink
plugins can get vConsole by this.vConsole after init event
Browse files Browse the repository at this point in the history
  • Loading branch information
Maizify committed Sep 21, 2017
1 parent d8457ff commit 370b835
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class VConsole {
*/
_initPlugin(plugin) {
let that = this;
plugin.setVConsole(this);
plugin.vConsole = this;
// start init
plugin.trigger('init');
// render tab (if it is a tab plugin then it should has tab-related events)
Expand Down
11 changes: 8 additions & 3 deletions src/lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class VConsolePlugin {
constructor(id, name = 'newPlugin') {
this.id = id;
this.name = name;
this.vConsole = null;

this.eventList = {};
}
Expand All @@ -43,8 +42,14 @@ class VConsolePlugin {
this._name = value;
}

setVConsole(obj) {
this.vConsole = obj;
get vConsole() {
return this._vConsole || undefined;
}
set vConsole(value) {
if (!value) {
throw 'vConsole cannot be empty';
}
this._vConsole = value;
}

/**
Expand Down

0 comments on commit 370b835

Please sign in to comment.