This file contains 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 fullSync(page = 1) { | |
let open = indexedDB.open("books", 1); | |
// Set up the database schema | |
open.onsuccess = evt => { | |
let db = open.result; | |
fullSyncPage(db, 1); | |
}; | |
} |
This file contains 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
// This should be declared as | |
// export function withActiveIndicator<T>(Component: FunctionComponent<T>): FunctionComponent<T> | |
// but styled components makes this extremely hard. For now, this approached brute forces the correct return type, | |
// so the result will be properly typed for the consumer, at the expense of some casts inside the function | |
export function withActiveIndicator<T>(Component: T): T { | |
const Wrapper = styled(Component as any)` | |
outline: 0; | |
&:focus > :first-child { | |
display: block; | |
} |
This file contains 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 React, { Component, createElement } from "react"; | |
import Enzyme, { shallow, render, mount } from "enzyme"; | |
import Adapter from "enzyme-adapter-react-16"; | |
import { action, observable, computed } from "mobx"; | |
import { observer } from "mobx-react"; | |
Enzyme.configure({ adapter: new Adapter() }); | |
class Store { | |
@observable val = 0; | |
} |
This file contains 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
var app = (function () { | |
'use strict'; | |
function noop() { } | |
function assign(tar, src) { | |
// @ts-ignore | |
for (const k in src) | |
tar[k] = src[k]; | |
return tar; | |
} |
This file contains 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
var app = (function () { | |
"use strict"; | |
function t() {} | |
function n(t) { | |
return t(); | |
} | |
function e() { | |
return Object.create(null); | |
} | |
function r(t) { |
This file contains 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
/* | |
Context is this brief twitter convo https://twitter.com/ryanflorence/status/1255655063021776897 | |
It would seem like Remix would need a way to allow developers to sync their SSR'd initial data into a client-side | |
GraphQL cache, like Apollo, if they're using one. | |
For example, if you have | |
*/ |
This file contains 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 useSuspenseQuery = options => { | |
const [resource] = useState(() => new DataQueryingThingWithState()); | |
resource.readLatest(options); //will throw a promise if not ready | |
useEffect(() => { | |
return () => resource.current.dispose(); //never call in the side rendering / "parallel universe" tree :( | |
}, []); | |
return resource.current.state; // or whatever |
This file contains 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
Stats accumulated from browser startup to previous page load; reload to get stats as of this page load. | |
Refresh | |
Histogram: ServiceWorkerCache.Cache.Keys2.IgnoreSearchDisabled recorded 7 samples, mean = 22.7 (flags = 0x41) | |
0 ------------------O (1 = 14.3%) | |
1 O (0 = 0.0%) {14.3%} | |
2 ------------------------------------------------------------------------O (4 = 57.1%) {14.3%} | |
3 ... | |
20 -----O (1 = 14.3%) {71.4%} | |
24 ... |
This file contains 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
export type BasicQuery<T extends keyof Query> = Pick<Query, T>; | |
export type AliasQuery<T extends Record<string, keyof Query>> = { [k in keyof T]: Query[T[k]] }; | |
export type CombinedQuery<T extends keyof Query, U extends Record<string, keyof Query>> = BasicQuery<T> & AliasQuery<U>; | |
const justTesting1 = useQuery<BasicQuery<"allBooks" | "allSubjects">>(null); | |
const { data: data1 } = justTesting1; | |
data1.allSubjects; | |
const justTesting2 = useQuery<AliasQuery<{ sub: "allSubjects"; sub2: "allSubjects" }>>(null); | |
const { data: data2 } = justTesting2; |
This file contains 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 subjectsReducer(state = initialSubjectsState(), action = {}){ | |
switch(action.type){ | |
case LOAD_SUBJECTS_RESULTS: | |
return Object.assign({}, state, { list: subjectsToHash(action.subjects) }); | |
case EDIT_SUBJECT: | |
var editingSubject = state.list[action._id], | |
newSubjectParent, | |
eligibleParents = flattenedSubjects(state.list).filter(s => s._id !== action._id && (!new RegExp(`,${action._id},`).test(s.path))); | |
if (editingSubject.path == null){ |
NewerOlder