Skip to content

Instantly share code, notes, and snippets.

View jakubriedl's full-sized avatar

Jakub Riedl jakubriedl

View GitHub Profile
@jakubriedl
jakubriedl / batchFetchExchange.ts
Last active June 10, 2023 04:13
URQL batchFetchExchange
import DataLoader from 'dataloader'
import { Exchange, Operation } from 'urql'
import { pipe, map } from 'wonka'
interface BatchRequest {
url: string
options?: RequestInit
}
const batchFetch = (
@jakubriedl
jakubriedl / 1asyncawait.js
Last active March 30, 2022 02:45 — forked from phuctm97/1asyncawait.js
Use Go Channels as Promises and Async/Await
// Javascript.
const one = async () => {
// Simulate a workload.
sleep(Math.floor(Math.random() * Math.floor(2000)))
return 1
}
const two = async () => {
// Simulate a workload.
@jakubriedl
jakubriedl / TinyBaseDurableObject.ts
Created July 19, 2025 02:56
TinyBase ws sync message partitioning
// this is just sync relevant snippet from the DO integration as it's heavily customised otherwise
const synchronizer = createCustomSynchronizer(
this.store,
(targetActorId, requestId, message, body) =>
createMessages(targetActorId, requestId, message, body).map((message) =>
this.handleMessage(SERVER_ACTOR_ID, message),
),
(receive: Receive) => {
this.forwardToServerActor = async (message: string) => {