podcast manager
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

rename gate to make more sense

+7 -6
+4 -3
src/common/once.ts src/common/gate.ts
··· 1 - export function onceMaker<F extends (...args: any[]) => void>( 1 + export function makeGate<F extends (...args: any[]) => void>( 2 2 outercb?: () => void, 3 3 ) { 4 4 let done = false; ··· 16 16 }, 17 17 18 18 many: (innercb: F) => (...args: Parameters<F>): void => { 19 - if (done) return; 20 - return innercb(...args); 19 + if (!done) { 20 + innercb(...args); 21 + } 21 22 }, 22 23 }; 23 24 }
+3 -3
src/common/socket.ts
··· 1 1 import { makeAbort, makeTimeoutAbort } from "./aborts.ts"; 2 2 import { BlockingAtom } from "./blocking-atom.ts"; 3 3 import { BlockingQueue } from "./blocking-queue.ts"; 4 - import { onceMaker } from "./once.ts"; 4 + import { makeGate } from "./gate.ts"; 5 5 6 6 export type StreamConfig = typeof STREAM_CONFIG_DEFAULT; 7 7 const STREAM_CONFIG_DEFAULT = { ··· 24 24 ): AsyncGenerator<unknown> { 25 25 const config = { ...STREAM_CONFIG_DEFAULT, ...config_ }; 26 26 const queue = new BlockingQueue<StreamEvent>(config.queueSize); 27 - const gate = onceMaker(); 27 + const gate = makeGate(); 28 28 29 29 const onMessage = gate.many((m: MessageEvent) => { 30 30 queue.enqueue(["yield", m.data]); ··· 81 81 ): Promise<MessageEvent["data"]> { 82 82 const atom = new BlockingAtom<MessageEvent["data"]>(); 83 83 const abort = ms ? makeTimeoutAbort(ms) : makeAbort(); 84 - const gate = onceMaker(); 84 + const gate = makeGate(); 85 85 86 86 // callback functions - consts so we can `off` them on clean up 87 87