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 makeQueue = () => { | |
let promise = Promise.resolve(); | |
return function queue(asyncFn) { | |
promise = promise.then(() => asyncFn()); | |
return promise; | |
}; | |
}; |
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 makeQueue = limit => { | |
const queue = []; | |
let concurrency = 0; | |
function enqueue(asyncFn) { | |
if (concurrency < limit) { | |
let curPromise = asyncFn().finally(() => { | |
concurrency -= 1; | |
const next = queue.shift(); |
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 FriendsList = props => { | |
const data = useFragment( | |
graphql` | |
fragment FriendsList_person on Person { | |
friends { | |
id | |
name | |
...FriendDetails_friend | |
} | |
} |
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 { | |
Todos_viewer, | |
Todos_viewer$key, | |
} from './_generated_/Todos_viewer.graphql'; | |
interface Props { | |
viewer: Todos_viewer$key; | |
} | |
export const Todos = ({ viewer }: Props) => { | |
const { todos }: Todos_viewer = useFragment( | |
graphql` |
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 { useState, useRef, useLayoutEffect, useMemo } from 'react'; | |
function getVpWidth() { | |
return typeof window !== 'undefined' | |
? Math.max( | |
window.document.documentElement.clientWidth, | |
window.innerWidth || 0 | |
) | |
: 0; | |
} |