this repo has no description
0
fork

Configure Feed

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

clear interval when disconnecting from the firehose

+6 -1
+6 -1
src/main.ts
··· 6 6 7 7 const subscribe = async () => { 8 8 let cursorFirehose = 0; 9 + let intervalID: NodeJS.Timeout; 9 10 const cursorFile = fs.readFileSync("cursor.txt", "utf8"); 10 11 11 12 const firehose = new Firehose({ cursor: cursorFile ?? "" }); ··· 16 17 }); 17 18 18 19 firehose.on("open", () => { 19 - setInterval(() => { 20 + intervalID = setInterval(() => { 20 21 const timestamp = new Date().toISOString(); 21 22 console.log(`${timestamp} cursor: ${cursorFirehose}`); 22 23 fs.writeFile("cursor.txt", cursorFirehose.toString(), (err) => { 23 24 if (err) console.error(err); 24 25 }); 25 26 }, 60000); 27 + }); 28 + 29 + firehose.on("close", () => { 30 + clearInterval(intervalID); 26 31 }); 27 32 28 33 firehose.on("commit", async (commit) => {