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
function syncItem(item, table, transform = item => item) { | |
let open = indexedDB.open("books", 1); | |
return new Promise(res => { | |
open.onsuccess = evt => { | |
let db = open.result; | |
let tran = db.transaction(table, "readwrite"); | |
let objStore = tran.objectStore(table); | |
objStore.get(item._id).onsuccess = ({ target: { result: itemToUpdate } }) => { | |
if (!itemToUpdate) { |
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 syncResultsFor({ request, response }, name, transform = item => item) { | |
let createNameSingle = `create${name}`; | |
if (response && response.data && response.data[createNameSingle] && response.data[createNameSingle][name]) { | |
syncItem(transform(response.data[createNameSingle][name]), `${name.toLowerCase()}s`); | |
} | |
let updateNameSingle = `update${name}`; | |
if (response && response.data && response.data[updateNameSingle] && response.data[updateNameSingle][name]) { | |
syncItem(transform(response.data[updateNameSingle][name]), `${name.toLowerCase()}s`); | |
} | |
let updateNamePlural = `update${name}s`; |
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
workbox.routing.registerRoute( | |
/graphql$/, | |
({ url, event }) => { | |
let request = event.request.clone(); | |
return fetch(event.request).then(response => { | |
let respClone = response.clone(); | |
respClone.json().then(response => { | |
syncResultsFor({ request, response }, "Book", bookSyncTransform); | |
syncResultsFor({ request, response }, "Tag"); |
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
function readTable(table, idxName) { | |
let open = indexedDB.open("books", 1); | |
return new Promise(resolve => { | |
open.onsuccess = evt => { | |
let db = open.result; | |
let tran = db.transaction(table); | |
let objStore = tran.objectStore(table); | |
let idx = objStore.index(idxName); | |
let tranCursor = idx.openCursor(); |
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
import allSubjects from "../graphQL/subjects/allSubjects.graphql"; | |
workbox.routing.registerRoute( | |
/graphql/, | |
({ url, event }) => { | |
return fetch(event.request).catch(err => { | |
let { query, variables } = parseQueryString(url.search); | |
if (query == allSubjects) { | |
return readTable("subjects", "name").then(gqlResponse("allSubjects", "Subjects")); |
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 GenerateSW({ | |
ignoreUrlParametersMatching: [/./], | |
exclude: [/\.(ttf|eot|svg|woff)$/], | |
navigateFallback: "react-redux/dist/index.html", | |
importScripts: ["react-redux/sw-manual/sw-index-bundle.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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
}); |
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
class ContactDetails extends Component { | |
render() { | |
return ( | |
<SomeUtility> | |
{(primitiveValue, SomeComponent) => ( | |
//QUESTION: you see that <SomeComponent /> component that <SomeUtility /> is providing in the | |
//render props? Is it possible for some piece of state from <SomeUtility /> to be passed to | |
//<SomeComponent /> ***automatically*** whenever it's rendered? | |
//The best I can come up with is to *create* de novo <SomeComponent /> in <SomeUtility />'s constructor |
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 glob = require("glob"), | |
fs = require("fs"); | |
/** Translate a glob expression to bundle arithmetic expression. Use this in your bundle definitions if you want to include based on glob expressions. */ | |
function jsGlob(globText) { | |
let regex = new RegExp("^../dist/"); | |
return ( | |
" ( " + | |
glob | |
.sync("../dist/" + globText) |
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
/* | |
See the readme for detailed guidance, as well as inline comments here. | |
*/ | |
const Builder = require("systemjs-builder"), | |
gulp = require("gulp"), | |
gulpIf = require("gulp-if"), | |
gulpUglify = require("gulp-uglify"), | |
gulpRename = require("gulp-rename"), | |
gulpPlumber = require("gulp-plumber"), |