PWA-Starter-Kit 요약

PWA-Starter-Kit 감상문

router.js

1
2
3
4
5
// IMPORT
import { installRouter } from 'pwa-helpers/router.js';

// ROUTING
installRouter((location) => handleNavigation(location));
1
2
3
4
5
6
// IMPORT
import { installRouter } from 'pwa-helpers/router.js';
import { navigate } from '../actions/app.js';

// ROUTING
installRouter((location) => store.dispatch(navigate(location)));
1
2
window.history.pushState({}, '', '/new-route');
handleNavigation(window.location);

자세히 보기

Mutation Observer 잘 쓰이는 코드 기록

Mutation Observer 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
console.log(mutation)
})
})

observer.observe(document.querySelector(`#div-exam`), {
attributes: true,
childList: true,
characterData: true,
subtree: true || null,
attributeOldValue: true || null,
characterDataOldValue: true || null,
})

document.querySelector(`#attr`).addEventListener(`click`, () => {
target.setAttribute(`class`, `attr`)
})

document.querySelector(`#child`).addEventListener(`click`, () => {
document.querySelector(`#div-exam`).textContent = `changed!`
})

나중에, 이걸 써서 프로젝트를 다시 해보자