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
// very loose idea of what we'd need | |
// query options would need to be defined separately | |
export const getTasksQueryOptions = (search: string) => { | |
return { | |
queryKey: ["tasks", search], | |
queryFn: async () => { | |
const tasks = await isoMorphicFetch(`/api/tasks?search=${search}`); | |
return tasks; | |
} |
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
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 readBooks(variableString) { | |
let variables = JSON.parse(variableString); | |
let { page = 1, pageSize = 50, title_contains, sort } = variables; | |
let predicate = null; | |
let limit = pageSize; | |
let skipAmount = (page - 1) * pageSize; | |
let skip, cursorSkip; | |
if (title_contains) { |
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 deleteItem(_id, table) { | |
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.delete(_id).onsuccess = res; | |
}; |
NewerOlder