This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new SWPrecacheWebpackPlugin({ | |
mergeStaticsConfig: true, | |
filename: "service-worker.js", | |
importScripts: ["../sw-manual.js"], // <------------------- new | |
staticFileGlobs: [ | |
"static/bootstrap/css/bootstrap-booklist-build.css", | |
"static/fontawesome/css/font-awesome-booklist-build.css", | |
"static/fontawesome/fonts/fontawesome-webfont.woff2", | |
"static/main-icon2.png", | |
"util/babelHelpers.min.js", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Offline Book tracker</title> | |
<link rel="stylesheet" href="react-redux/static/bootstrap/css/bootstrap-booklist-build.css"> | |
<link rel="stylesheet" href="react-redux/static/fontawesome/css/font-awesome-booklist-build.css"> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ("serviceWorker" in navigator) { | |
navigator.serviceWorker.register("/service-worker.js"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toolbox.router.get(/^https:\/\/images-na.ssl-images-amazon.com/, toolbox.cacheFirst, { | |
cache: { maxEntries: 500, name: "amazon-images1", maxAgeSeconds: 63072000 }, | |
successResponses: /0|[123].*/ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inside your webpack config | |
const getCache = ({ name, pattern, expires, maxEntries }) => ({ | |
urlPattern: pattern, | |
handler: "cacheFirst", | |
options: { | |
cache: { | |
maxEntries: maxEntries || 500, | |
name: name, | |
maxAgeSeconds: expires || 60 * 60 * 24 * 365 * 2 //2 years |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function a(){ | |
console.log("a"); | |
b(); | |
console.log("b done"); | |
} | |
async function b(){ | |
console.log("starting b"); | |
await Promise.resolve(res => setTimeout(() => res()), 1000); | |
console.log("finishing b"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const combineLazyReducers = (reducers, initialState) => { | |
initialState = initialState || {}; | |
let handler = { | |
ownKeys(target){ | |
return Array.from(new Set([...Reflect.ownKeys(target), ...Reflect.ownKeys(initialState)])); | |
}, | |
get(target, key){ | |
return target[key] || (state => state === undefined ? null : state); | |
}, | |
getOwnPropertyDescriptor(target, key){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const combineLazyReducers = (reducers, initialState) => { | |
let reducerKeys = new Set(Object.keys(reducers)); | |
Object.keys(initialState) | |
.filter(k => !reducerKeys.has(k)) | |
.forEach(k => { | |
reducers[k] = state => state === undefined ? null : state | |
}); | |
return combineReducers(reducers); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const combineLazyReducers = (reducers, initialState) => { | |
let reducer = combineReducers(reducers); | |
return (state, action) => ({...initialState, ...reducer(state, action)}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const storeInitialState = { | |
app: { rootA: 10, rootB: 12 }, | |
aModule: { aValue: 'saved A value' }, | |
bModule: { bValue: 'saved B value' }, | |
} | |
const store = createStore(combineLazyReducers({app: rootReducer}, storeInitialState), storeInitialState); | |
const asyncReducers = {}; | |
const getNewReducer = newModuleInfo => { |