-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
31 lines (29 loc) · 1.2 KB
/
main.js
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
// Import modules
import { makeFretStore } from './modules/fretStore.js';
import { mount, displayFretboard, displayMenu, displayHighlights } from './modules/display.js';
import { setEventHandler } from './modules/eventHandler.js';
import { makeObserverController, addObserver, mutate, fire } from './modules/observer.js';
const fretStore = makeFretStore();
const observerController = makeObserverController(fretStore);
addObserver(observerController, () => {
const fretboardDisplay = displayFretboard(fretStore);
mount('#fretboard-viewport', fretboardDisplay);
});
addObserver(observerController, () => {
const menuDisplay = displayMenu(fretStore);
mount('#menu-viewport', menuDisplay);
});
addObserver(observerController, () => {
displayHighlights(fretStore);
});
addObserver(observerController, () => {
const eventHandler = setEventHandler(fretStore, observerController, mutate);
});
fretStore.highlightNotes[3].display = true;
mutate(observerController, {highlightNotes: fretStore.highlightNotes});
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./serviceWorker.js')
.then(console.log('sw registered'));
});
}