Skip to content

Commit fbbcde6

Browse files
committed
clean up code
1 parent ab1d55d commit fbbcde6

File tree

4 files changed

+27
-34
lines changed

4 files changed

+27
-34
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"webpack-cli": "^3.1.0"
3535
},
3636
"dependencies": {},
37-
"license" : "MIT",
37+
"license": "MIT",
3838
"importSort": {
3939
".js, .jsx, .ts, .tsx": {
4040
"parser": "typescript",

src/TitleBar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export class TitleBar extends React.Component {
4848
<span className="elastic-space" />
4949
{this.model.state.graph.ids.length > 0
5050
? [
51-
<a className="secondary-link" onClick={this.onClickShowHelp}>
51+
<a
52+
className="secondary-link"
53+
onClick={this.onClickShowHelp}
54+
>
5255
{texts.help + " "}
5356
<Icon type="question-circle-o" />
5457
</a>,

src/serial.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ export interface RunOption {
1010
}
1111

1212
export class Serial {
13-
private _queue: Task<any>[];
14-
private _running: boolean;
15-
private _triggers: Map<string, { func: () => void; active: boolean }>;
16-
17-
constructor() {
18-
this._queue = [];
19-
this._running = false;
20-
this._triggers = new Map();
21-
}
13+
private _queue: Task<any>[] = [];
14+
private _running: boolean = false;
15+
private _triggers: Map<
16+
string,
17+
{ func: () => void; active: boolean }
18+
> = new Map();
2219

2320
subscribe(name: string, func: () => void) {
2421
this._triggers.set(name, { func, active: false });

src/view-model.ts

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import { Snapshot } from "./link-stack.h";
55
import { Message, MsgType, createIntention, isMessage } from "./message";
66

77
class Delayer {
8-
private _handle: number | null;
9-
10-
constructor() {
11-
this._handle = null;
12-
}
8+
private _handle: number | null = null;
139

1410
later(func: (...args: any[]) => void, timeout: number) {
1511
if (this._handle !== null) clearTimeout(this._handle);
@@ -31,26 +27,23 @@ export interface ViewModelState extends Snapshot {
3127
}
3228

3329
export class ViewModel {
34-
state: ViewModelState;
35-
36-
private _port: browser.runtime.Port;
37-
private _listeners: ((state: ViewModelState) => void)[];
38-
private _updateDelayer: Delayer;
30+
state: ViewModelState = {
31+
name: null,
32+
id: null,
33+
graph: emptyGraph(),
34+
monotron: 0,
35+
unsyncedUpdate: true,
36+
bookmarkTreeSelection: null,
37+
modal: ModalState.None
38+
};
39+
40+
private _port: browser.runtime.Port = browser.runtime.connect({
41+
name: "view"
42+
});
43+
private _listeners: ((state: ViewModelState) => void)[] = [];
44+
private _updateDelayer: Delayer = new Delayer();
3945

4046
constructor() {
41-
this.state = {
42-
name: null,
43-
id: null,
44-
graph: emptyGraph(),
45-
monotron: 0,
46-
unsyncedUpdate: true,
47-
bookmarkTreeSelection: null,
48-
modal: ModalState.None
49-
};
50-
this._port = browser.runtime.connect({ name: "view" });
51-
this._listeners = [];
52-
this._updateDelayer = new Delayer();
53-
5447
this._port.onMessage.addListener(o => this.dispatch(o as any));
5548

5649
this.dispatch(createIntention("_init"));

0 commit comments

Comments
 (0)