Skip to content

Commit 02cafd1

Browse files
committed
refactor: define inline access modifiers and initializers
1 parent b6e9ac0 commit 02cafd1

File tree

8 files changed

+45
-83
lines changed

8 files changed

+45
-83
lines changed

packages/node_modules/action-chain/src/ActionBase.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { ActionChain, Execution, ExecutionContext } from './ActionChain'
22

33
export class StopExecution {
4-
value: any
5-
constructor(value) {
6-
this.value = value
7-
}
4+
constructor(public value) {}
85
}
96
export class ActionBase<Effects> {
107
static nextActionId: number = 0

packages/node_modules/betsy/src/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ export type Listener = {
44
}
55

66
export class EventEmitter<T> {
7-
private events: Map<keyof T, Listener[]>
8-
9-
constructor() {
10-
this.events = new Map()
11-
}
7+
private events = new Map<keyof T, Listener[]>()
128

139
emit<K extends keyof T>(event: K, msg: T[K]) {
1410
const listeners = this.events.get(event) || []

packages/node_modules/overmind/src/Action.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ProxyStateTree from 'proxy-state-tree'
2-
import { ActionBase, StopExecution } from 'action-chain'
2+
import { ActionBase, StopExecution, ActionChain } from 'action-chain'
33

44
type OperatorCallback<Effects, Value, NewValue = Value> = (
55
effects: Effects,
@@ -30,10 +30,13 @@ export default class Action<
3030
InitialValue,
3131
Value = InitialValue
3232
> extends ActionBase<Effects> {
33-
private proxyStateTree: ProxyStateTree
34-
constructor(proxyStateTree, actionChain, initialActionId?, runOperators?) {
33+
constructor(
34+
private proxyStateTree: ProxyStateTree,
35+
actionChain: ActionChain<Effects>,
36+
initialActionId?: number,
37+
runOperators?
38+
) {
3539
super(actionChain, initialActionId, runOperators)
36-
this.proxyStateTree = proxyStateTree
3740
}
3841
fork: <Paths>(
3942
cb: (effects: Effects, value: Value) => keyof Paths,

packages/node_modules/overmind/src/Devtools.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,12 @@ function debounce(func, wait) {
4040
}
4141

4242
export default class Devtools {
43-
buffer: string[]
44-
ws: WebSocket
45-
isConnected: boolean
46-
doReconnect: boolean
47-
hasWarnedReconnect: boolean
48-
reconnectInterval: number
49-
constructor() {
50-
this.ws = null
51-
this.isConnected = false
52-
this.doReconnect = false
53-
this.reconnectInterval = 10000
54-
this.hasWarnedReconnect = false
55-
this.buffer = []
56-
}
43+
private buffer: string[] = []
44+
private ws: WebSocket = null
45+
private isConnected: boolean = false
46+
private doReconnect: boolean = false
47+
private hasWarnedReconnect: boolean = false
48+
private reconnectInterval: number = 10000
5749
connect = (host: string, onMessage: (message: Message) => void) => {
5850
this.ws = new WebSocket(`ws://${host}`)
5951
this.ws.onmessage = (event) => onMessage(JSON.parse(event.data))

packages/node_modules/overmind/src/computed.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ type Cache = {
1515
}
1616

1717
export class Computed {
18-
cb: (config: any) => (state: object) => void
19-
cacheLimit: number = 10
20-
cacheKeys: Cache[] = []
21-
cache: Map<any, Cache> = new Map()
22-
constructor(cb, options: ComputedOptions = {}) {
23-
this.cb = cb
18+
private cacheLimit: number = 10
19+
private cacheKeys: Cache[] = []
20+
private cache: Map<any, Cache> = new Map()
21+
constructor(
22+
private cb: (config: any) => (state: object) => void,
23+
options: ComputedOptions = {}
24+
) {
2425
this.cacheLimit = options.cacheLimit || this.cacheLimit
2526
return this.evaluate.bind(this)
2627
}

packages/node_modules/overmind/src/derived.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@ import ProxyStateTree from 'proxy-state-tree'
33
import { Events, EventType } from './'
44

55
class Derived {
6-
isDirty: boolean
7-
proxyStateTreeListener: any
8-
value: any
9-
cb: (state: object) => void
10-
paths: Set<string>
11-
updateCount: number
12-
constructor(cb) {
13-
this.isDirty = true
14-
this.proxyStateTreeListener = null
15-
this.value = null
16-
this.cb = cb
17-
this.updateCount = 0
6+
private isDirty: boolean = true
7+
private proxyStateTreeListener: any = null
8+
private value: any = null
9+
private paths: Set<string>
10+
private updateCount: number = 0
11+
constructor(private cb: (state: object) => void) {
1812
return this.evaluate.bind(this)
1913
}
2014
evaluate(

packages/node_modules/overmind/src/reaction.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,14 @@ import ProxyStateTree from 'proxy-state-tree'
33
import { Events, EventType } from './'
44

55
class Reaction {
6-
eventHub: EventEmitter<Events>
7-
proxyStateTree: ProxyStateTree
8-
path: string
9-
proxyStateTreeListener: any
10-
statePath: string
11-
updateCount: number
6+
private proxyStateTreeListener: any = null
7+
private updateCount: number = 0
8+
private statePath: string
129
constructor(
13-
eventHub: EventEmitter<Events>,
14-
proxyStateTree: ProxyStateTree,
15-
path
16-
) {
17-
this.eventHub = eventHub
18-
this.proxyStateTree = proxyStateTree
19-
this.path = path
20-
this.proxyStateTreeListener = null
21-
this.updateCount = 0
22-
}
10+
private eventHub: EventEmitter<Events>,
11+
private proxyStateTree: ProxyStateTree,
12+
private path: string
13+
) {}
2314
create(stateCb: (state: object) => any, cb: any) {
2415
const trackId = this.proxyStateTree.startPathsTracking()
2516
stateCb(this.proxyStateTree.get())

packages/node_modules/proxy-state-tree/src/index.ts

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@ export type Mutation = {
1313
}
1414

1515
class ProxyStateTree {
16-
state: object
17-
options: Options
18-
pathDependencies: object
19-
globalDependencies: Set<Function>
20-
objectChanges: Set<string>
21-
mutations: Mutation[]
22-
currentMutations: Mutation[]
23-
paths: Set<string>[]
24-
status: STATUS
25-
proxy: any
26-
currentFlushId: number
27-
constructor(state: object, options: Options = {}) {
16+
pathDependencies: object = {}
17+
private globalDependencies = new Set<Function>()
18+
private objectChanges = new Set<string>()
19+
private mutations: Mutation[] = []
20+
private currentMutations: Mutation[] = []
21+
private paths: Set<string>[] = []
22+
private status: STATUS = STATUS.IDLE
23+
private currentFlushId: number = 0
24+
private proxy: any
25+
constructor(private state: object, private options: Options = {}) {
2826
if (!isPlainObject(state)) {
2927
throw new Error(
3028
'You did not pass a plain object as state to Proxy State Tree'
@@ -35,17 +33,7 @@ class ProxyStateTree {
3533
options.devmode = true
3634
}
3735

38-
this.state = state
39-
this.options = options
40-
this.pathDependencies = {}
41-
this.globalDependencies = new Set()
42-
this.mutations = []
43-
this.currentMutations = []
44-
this.paths = []
45-
this.objectChanges = new Set()
46-
this.status = STATUS.IDLE
4736
this.proxy = proxify(this, state)
48-
this.currentFlushId = 0
4937
}
5038
get() {
5139
return this.proxy

0 commit comments

Comments
 (0)