-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModBank.js
More file actions
44 lines (43 loc) · 881 Bytes
/
Copy pathModBank.js
File metadata and controls
44 lines (43 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Store {
constructor() {
this.banks = {}
this.objectBanks = {}
}
addBank(bankName, data) {
this.banks[bankName] = data
this.objectBanks[bankName] = []
}
getData(bankName) {
return this.banks[bankName]
}
setData(bankName, newData) {
this.banks[bankName] = newData
this.updateModules(bankName)
}
addModule(bankName, mod) {
this.objectBanks[bankName].push(mod)
}
updateModules(bankName) {
this.objectBanks[bankName].forEach((obj)=> {
obj.update(this)
})
}
}
class Mod {
constructor(id, store, ...bankNames) {
this.id = id
this.store = store
bankNames.forEach((bankName)=> {
this.store.addModule(bankName, this)
})
}
render() {
this.$html = $(``)
$(this.id).empty()
$(this.id).append(this.$html)
}
update(newData) {
this.store = newData
this.render()
}
}