Skip to content

Commit c984c74

Browse files
committed
adding some options to the dev tools launcher so you can open it right away
1 parent 29b4941 commit c984c74

3 files changed

Lines changed: 25 additions & 17 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "esp-js-devtools",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"description": "Evented State Processor (ESP) dev tools",
55
"main": "dist/esp-js-devtools.js",
66
"scripts": {
@@ -26,7 +26,7 @@
2626
"devDependencies": {
2727
"babel-core": "^6.4.5",
2828
"babel-loader": "^6.2.1",
29-
"esp-js": "0.5.7-beta",
29+
"esp-js": "0.5.15",
3030
"babel-plugin-transform-decorators-legacy": "^1.3.4",
3131
"babel-preset-es2015": "^6.3.13",
3232
"babel-preset-react": "^6.3.13",

src/devtoolsHooks.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ import DevToolsModel from './model/devToolsModel';
2323
import DevToolsView from './views/devToolsView';
2424

2525
class Controller {
26-
constructor() {
26+
constructor(options) {
2727
this._model = null;
2828
this._view = null;
2929
this._router = null;
30+
this._options = options;
3031
}
3132
start() {
3233
this._router = new esp.Router();
33-
this._model = new DevToolsModel(this._router);
34+
this._model = new DevToolsModel(this._router, this._options);
3435
this._router.addModel(DevToolsModel.modelId, this._model);
3536
window.__espAnalyticsMonitor = new AnalyticsMonitor(DevToolsModel.modelId, this._router);
3637
this._model.observeEvents();
@@ -47,30 +48,37 @@ class Controller {
4748
_openDevToolsOnKeyboardShortcut(event) {
4849
event = event || window.event;
4950
if(event.keyCode== 68 && event.ctrlKey && event.altKey) {
50-
if(this._view === null) {
51-
this._view = new DevToolsView(DevToolsModel.modelId, this._router);
52-
this._view.start();
53-
this._view.addDisposable(
54-
() => {
55-
this._view = null;
56-
}
57-
);
58-
}
51+
this.tryOpenDevTools();
52+
}
53+
}
54+
tryOpenDevTools() {
55+
if(this._view === null) {
56+
this._view = new DevToolsView(DevToolsModel.modelId, this._router);
57+
this._view.start();
58+
this._view.addDisposable(
59+
() => {
60+
this._view = null;
61+
}
62+
);
5963
}
6064
}
6165
}
6266

6367
let isRegistered = false;
6468
let controller;
6569

66-
export function registerDevTools() {
70+
export function registerDevTools(options) {
6771
if (isRegistered) {
6872
return;
6973
}
7074
if (typeof window === 'undefined') {
7175
throw new Error('window is undefined. esp-devtools needs window to add a hook to window for all routers to interact with');
7276
}
77+
let devToolsOptions = options || {};
7378
isRegistered = true;
74-
controller = new Controller();
79+
controller = new Controller(devToolsOptions);
7580
controller.start();
81+
if(devToolsOptions.displayOnStartup) {
82+
controller.tryOpenDevTools();
83+
}
7684
}

src/model/devToolsModel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import DataPoint from './dataPoint';
2525
import DataPointType from './dataPointType';
2626

2727
export default class DevToolsModel extends esp.model.DisposableBase {
28-
constructor(router) {
28+
constructor(router, options) {
2929
super();
3030
this._router = router;
3131
this._registeredModels = {};
@@ -40,7 +40,7 @@ export default class DevToolsModel extends esp.model.DisposableBase {
4040
this._now = moment();
4141
this._shouldAutoScroll = true;
4242
this._shouldCaptureEvents = true;
43-
this._shouldLogToConsole = false;
43+
this._shouldLogToConsole = options.logEventsToConsole ? true : false;
4444
this._dataPointBufferSize = 200;
4545
}
4646
static get modelId() {

0 commit comments

Comments
 (0)